/*-------------------------------------------------------------------------
 *
 * copyfuncs.c
 *	  Postgres 树节点的复制函数。
 *
 * 注意：我们当前支持复制解析和计划树中发现的所有节点类型。
 * 我们不支持复制执行器状态树；没有必要这样做，也没有必要维护
 * 所有需要的代码。我们也不支持复制 Path 树，主要是因为  
 * RelOptInfo 和 Path 节点之间的循环链接无法在简单的深度优先
 * 遍历中轻松处理。
 *
 *
 * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * IDENTIFICATION
 *	  src/backend/nodes/copyfuncs.c
 *
 *-------------------------------------------------------------------------
 */

#include "postgres.h"

#include "miscadmin.h"
#include "nodes/extensible.h"
#include "nodes/pathnodes.h"
#include "nodes/plannodes.h"
#include "utils/datum.h"
#include "utils/rel.h"


/*
 * 宏以简化不同类型字段的复制。 
 * 在可能的情况下使用这些来减少愚蠢的打字错误的机会。
 * 注意这些硬编码了 Copy 例程中的局部变量命名为 'newnode' 和 'from' 的约定。
 */

/* 复制一个简单的标量字段（int, float, bool, enum 等） */
#define COPY_SCALAR_FIELD(fldname) \
	(fc_newnode->fldname = fc_from->fldname)

/* 复制一个指向某种 Node 或 Node 树的指针字段 */
#define COPY_NODE_FIELD(fldname) \
	(fc_newnode->fldname = copyObjectImpl(fc_from->fldname))

/* 复制一个指向 Bitmapset 的指针字段 */
#define COPY_BITMAPSET_FIELD(fldname) \
	(fc_newnode->fldname = bms_copy(fc_from->fldname))

/* 复制一个指向 C 字符串的指针字段，或可能为 NULL */
#define COPY_STRING_FIELD(fldname) \
	(fc_newnode->fldname = fc_from->fldname ? pstrdup(fc_from->fldname) : (char *) NULL)

/* 复制一个内联数组的字段 */
#define COPY_ARRAY_FIELD(fldname) \
	memcpy(fc_newnode->fldname, fc_from->fldname, sizeof(fc_newnode->fldname))

/* 复制一个指向简单 palloc' 对象的指针字段，大小为 sz */
#define COPY_POINTER_FIELD(fldname, sz) \
	do { \
		Size	fc__size = (sz); \
		if (fc__size > 0) \
		{ \
			fc_newnode->fldname = palloc(fc__size); \
			memcpy(fc_newnode->fldname, fc_from->fldname, fc__size); \
		} \
	} while (0)

/* 复制一个解析位置字段（对于 Copy，这与标量情况相同） */
#define COPY_LOCATION_FIELD(fldname) \
	(fc_newnode->fldname = fc_from->fldname)


/* ****************************************************************
 *					 plannodes.h 复制函数
 * ****************************************************************
 */

/*
 * _copyPlannedStmt
 */
static PlannedStmt * fc__copyPlannedStmt(const PlannedStmt *fc_from)
{
	PlannedStmt *fc_newnode = makeNode(PlannedStmt);

	COPY_SCALAR_FIELD(commandType);
	COPY_SCALAR_FIELD(queryId);
	COPY_SCALAR_FIELD(hasReturning);
	COPY_SCALAR_FIELD(hasModifyingCTE);
	COPY_SCALAR_FIELD(canSetTag);
	COPY_SCALAR_FIELD(transientPlan);
	COPY_SCALAR_FIELD(dependsOnRole);
	COPY_SCALAR_FIELD(parallelModeNeeded);
	COPY_SCALAR_FIELD(jitFlags);
	COPY_NODE_FIELD(planTree);
	COPY_NODE_FIELD(rtable);
	COPY_NODE_FIELD(resultRelations);
	COPY_NODE_FIELD(appendRelations);
	COPY_NODE_FIELD(subplans);
	COPY_BITMAPSET_FIELD(rewindPlanIDs);
	COPY_NODE_FIELD(rowMarks);
	COPY_NODE_FIELD(relationOids);
	COPY_NODE_FIELD(invalItems);
	COPY_NODE_FIELD(paramExecTypes);
	COPY_NODE_FIELD(utilityStmt);
	COPY_LOCATION_FIELD(stmt_location);
	COPY_SCALAR_FIELD(stmt_len);

	return fc_newnode;
}

/*
 * CopyPlanFields
 *
 *		此函数复制 Plan 节点的字段。它由所有来自 Plan 的复制函数使用。
 */
static void fc_CopyPlanFields(const Plan *fc_from, Plan *fc_newnode)
{
	COPY_SCALAR_FIELD(startup_cost);
	COPY_SCALAR_FIELD(total_cost);
	COPY_SCALAR_FIELD(plan_rows);
	COPY_SCALAR_FIELD(plan_width);
	COPY_SCALAR_FIELD(parallel_aware);
	COPY_SCALAR_FIELD(parallel_safe);
	COPY_SCALAR_FIELD(async_capable);
	COPY_SCALAR_FIELD(plan_node_id);
	COPY_NODE_FIELD(targetlist);
	COPY_NODE_FIELD(qual);
	COPY_NODE_FIELD(lefttree);
	COPY_NODE_FIELD(righttree);
	COPY_NODE_FIELD(initPlan);
	COPY_BITMAPSET_FIELD(extParam);
	COPY_BITMAPSET_FIELD(allParam);
}

/*
 * _copyPlan
 */
static Plan * fc__copyPlan(const Plan *fc_from)
{
	Plan	   *fc_newnode = makeNode(Plan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields(fc_from, fc_newnode);

	return fc_newnode;
}


/*
 * _copyResult
 */
static Result * fc__copyResult(const Result *fc_from)
{
	Result	   *fc_newnode = makeNode(Result);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(resconstantqual);

	return fc_newnode;
}

/*
 * _copyProjectSet
 */
static ProjectSet * fc__copyProjectSet(const ProjectSet *fc_from)
{
	ProjectSet *fc_newnode = makeNode(ProjectSet);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	return fc_newnode;
}

/*
 * _copyModifyTable
 */
static ModifyTable * fc__copyModifyTable(const ModifyTable *fc_from)
{
	ModifyTable *fc_newnode = makeNode(ModifyTable);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(operation);
	COPY_SCALAR_FIELD(canSetTag);
	COPY_SCALAR_FIELD(nominalRelation);
	COPY_SCALAR_FIELD(rootRelation);
	COPY_SCALAR_FIELD(partColsUpdated);
	COPY_NODE_FIELD(resultRelations);
	COPY_NODE_FIELD(updateColnosLists);
	COPY_NODE_FIELD(withCheckOptionLists);
	COPY_NODE_FIELD(returningLists);
	COPY_NODE_FIELD(fdwPrivLists);
	COPY_BITMAPSET_FIELD(fdwDirectModifyPlans);
	COPY_NODE_FIELD(rowMarks);
	COPY_SCALAR_FIELD(epqParam);
	COPY_SCALAR_FIELD(onConflictAction);
	COPY_NODE_FIELD(arbiterIndexes);
	COPY_NODE_FIELD(onConflictSet);
	COPY_NODE_FIELD(onConflictCols);
	COPY_NODE_FIELD(onConflictWhere);
	COPY_SCALAR_FIELD(exclRelRTI);
	COPY_NODE_FIELD(exclRelTlist);
	COPY_NODE_FIELD(mergeActionLists);

	return fc_newnode;
}

/*
 * _copyAppend
 */
static Append *
fc__copyAppend(const Append *fc_from)
{
	Append	   *fc_newnode = makeNode(Append);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_BITMAPSET_FIELD(apprelids);
	COPY_NODE_FIELD(appendplans);
	COPY_SCALAR_FIELD(nasyncplans);
	COPY_SCALAR_FIELD(first_partial_plan);
	COPY_NODE_FIELD(part_prune_info);

	return fc_newnode;
}

/*
 * _copyMergeAppend
 */
static MergeAppend *
fc__copyMergeAppend(const MergeAppend *fc_from)
{
	MergeAppend *fc_newnode = makeNode(MergeAppend);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_BITMAPSET_FIELD(apprelids);
	COPY_NODE_FIELD(mergeplans);
	COPY_SCALAR_FIELD(numCols);
	COPY_POINTER_FIELD(sortColIdx, fc_from->numCols * sizeof(AttrNumber));
	COPY_POINTER_FIELD(sortOperators, fc_from->numCols * sizeof(Oid));
	COPY_POINTER_FIELD(collations, fc_from->numCols * sizeof(Oid));
	COPY_POINTER_FIELD(nullsFirst, fc_from->numCols * sizeof(bool));
	COPY_NODE_FIELD(part_prune_info);

	return fc_newnode;
}

/*
 * _copyRecursiveUnion
 */
static RecursiveUnion * fc__copyRecursiveUnion(const RecursiveUnion *fc_from)
{
	RecursiveUnion *fc_newnode = makeNode(RecursiveUnion);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(wtParam);
	COPY_SCALAR_FIELD(numCols);
	COPY_POINTER_FIELD(dupColIdx, fc_from->numCols * sizeof(AttrNumber));
	COPY_POINTER_FIELD(dupOperators, fc_from->numCols * sizeof(Oid));
	COPY_POINTER_FIELD(dupCollations, fc_from->numCols * sizeof(Oid));
	COPY_SCALAR_FIELD(numGroups);

	return fc_newnode;
}

/*
 * _copyBitmapAnd
 */
static BitmapAnd * fc__copyBitmapAnd(const BitmapAnd *fc_from)
{
	BitmapAnd  *fc_newnode = makeNode(BitmapAnd);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(bitmapplans);

	return fc_newnode;
}

/*
 * _copyBitmapOr
 */
static BitmapOr * fc__copyBitmapOr(const BitmapOr *fc_from)
{
	BitmapOr   *fc_newnode = makeNode(BitmapOr);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(isshared);
	COPY_NODE_FIELD(bitmapplans);

	return fc_newnode;
}

/*
 * _copyGather
 */
static Gather * fc__copyGather(const Gather *fc_from)
{
	Gather	   *fc_newnode = makeNode(Gather);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(num_workers);
	COPY_SCALAR_FIELD(rescan_param);
	COPY_SCALAR_FIELD(single_copy);
	COPY_SCALAR_FIELD(invisible);
	COPY_BITMAPSET_FIELD(initParam);

	return fc_newnode;
}

/*
 * _copyGatherMerge
 */
static GatherMerge * fc__copyGatherMerge(const GatherMerge *fc_from)
{
	GatherMerge *fc_newnode = makeNode(GatherMerge);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(num_workers);
	COPY_SCALAR_FIELD(rescan_param);
	COPY_SCALAR_FIELD(numCols);
	COPY_POINTER_FIELD(sortColIdx, fc_from->numCols * sizeof(AttrNumber));
	COPY_POINTER_FIELD(sortOperators, fc_from->numCols * sizeof(Oid));
	COPY_POINTER_FIELD(collations, fc_from->numCols * sizeof(Oid));
	COPY_POINTER_FIELD(nullsFirst, fc_from->numCols * sizeof(bool));
	COPY_BITMAPSET_FIELD(initParam);

	return fc_newnode;
}

/*
 * CopyScanFields
 *
 *		此函数复制扫描节点的字段。它被所有继承自Scan的类的复制函数使用。
 */
static void fc_CopyScanFields(const Scan *fc_from, Scan *fc_newnode)
{
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	COPY_SCALAR_FIELD(scanrelid);
}

/*
 * _copyScan
 */
static Scan * fc__copyScan(const Scan *fc_from)
{
	Scan	   *fc_newnode = makeNode(Scan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	return fc_newnode;
}

/*
 * _copySeqScan
 */
static SeqScan * fc__copySeqScan(const SeqScan *fc_from)
{
	SeqScan    *fc_newnode = makeNode(SeqScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	return fc_newnode;
}

/*
 * _copySampleScan
 */
static SampleScan * fc__copySampleScan(const SampleScan *fc_from)
{
	SampleScan *fc_newnode = makeNode(SampleScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(tablesample);

	return fc_newnode;
}

/*
 * _copyIndexScan
 */
static IndexScan * fc__copyIndexScan(const IndexScan *fc_from)
{
	IndexScan  *fc_newnode = makeNode(IndexScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(indexid);
	COPY_NODE_FIELD(indexqual);
	COPY_NODE_FIELD(indexqualorig);
	COPY_NODE_FIELD(indexorderby);
	COPY_NODE_FIELD(indexorderbyorig);
	COPY_NODE_FIELD(indexorderbyops);
	COPY_SCALAR_FIELD(indexorderdir);

	return fc_newnode;
}

/*
 * _copyIndexOnlyScan
 */
static IndexOnlyScan * fc__copyIndexOnlyScan(const IndexOnlyScan *fc_from)
{
	IndexOnlyScan *fc_newnode = makeNode(IndexOnlyScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(indexid);
	COPY_NODE_FIELD(indexqual);
	COPY_NODE_FIELD(recheckqual);
	COPY_NODE_FIELD(indexorderby);
	COPY_NODE_FIELD(indextlist);
	COPY_SCALAR_FIELD(indexorderdir);

	return fc_newnode;
}

/*
 * _copyBitmapIndexScan
 */
static BitmapIndexScan * fc__copyBitmapIndexScan(const BitmapIndexScan *fc_from)
{
	BitmapIndexScan *fc_newnode = makeNode(BitmapIndexScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(indexid);
	COPY_SCALAR_FIELD(isshared);
	COPY_NODE_FIELD(indexqual);
	COPY_NODE_FIELD(indexqualorig);

	return fc_newnode;
}

/*
 * _copyBitmapHeapScan
 */
static BitmapHeapScan * fc__copyBitmapHeapScan(const BitmapHeapScan *fc_from)
{
	BitmapHeapScan *fc_newnode = makeNode(BitmapHeapScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(bitmapqualorig);

	return fc_newnode;
}

/*
 * _copyTidScan
 */
static TidScan * fc__copyTidScan(const TidScan *fc_from)
{
	TidScan    *fc_newnode = makeNode(TidScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(tidquals);

	return fc_newnode;
}

/*
 * _copyTidRangeScan
 */
static TidRangeScan * fc__copyTidRangeScan(const TidRangeScan *fc_from)
{
	TidRangeScan *fc_newnode = makeNode(TidRangeScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(tidrangequals);

	return fc_newnode;
}

/*
 * _copySubqueryScan
 */
static SubqueryScan * fc__copySubqueryScan(const SubqueryScan *fc_from)
{
	SubqueryScan *fc_newnode = makeNode(SubqueryScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(subplan);
	COPY_SCALAR_FIELD(scanstatus);

	return fc_newnode;
}

/*
 * _copyFunctionScan
 */
static FunctionScan * fc__copyFunctionScan(const FunctionScan *fc_from)
{
	FunctionScan *fc_newnode = makeNode(FunctionScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(functions);
	COPY_SCALAR_FIELD(funcordinality);

	return fc_newnode;
}

/*
 * _copyTableFuncScan
 */
static TableFuncScan * fc__copyTableFuncScan(const TableFuncScan *fc_from)
{
	TableFuncScan *fc_newnode = makeNode(TableFuncScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(tablefunc);

	return fc_newnode;
}

/*
 * _copyValuesScan
 */
static ValuesScan * fc__copyValuesScan(const ValuesScan *fc_from)
{
	ValuesScan *fc_newnode = makeNode(ValuesScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(values_lists);

	return fc_newnode;
}

/*
 * _copyCteScan
 */
static CteScan * fc__copyCteScan(const CteScan *fc_from)
{
	CteScan    *fc_newnode = makeNode(CteScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(ctePlanId);
	COPY_SCALAR_FIELD(cteParam);

	return fc_newnode;
}

/*
 * _copyNamedTuplestoreScan
 */
static NamedTuplestoreScan * fc__copyNamedTuplestoreScan(const NamedTuplestoreScan *fc_from)
{
	NamedTuplestoreScan *fc_newnode = makeNode(NamedTuplestoreScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_STRING_FIELD(enrname);

	return fc_newnode;
}

/*
 * _copyWorkTableScan
 */
static WorkTableScan * fc__copyWorkTableScan(const WorkTableScan *fc_from)
{
	WorkTableScan *fc_newnode = makeNode(WorkTableScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(wtParam);

	return fc_newnode;
}

/*
 * _copyForeignScan
 */
static ForeignScan * fc__copyForeignScan(const ForeignScan *fc_from)
{
	ForeignScan *fc_newnode = makeNode(ForeignScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(operation);
	COPY_SCALAR_FIELD(resultRelation);
	COPY_SCALAR_FIELD(fs_server);
	COPY_NODE_FIELD(fdw_exprs);
	COPY_NODE_FIELD(fdw_private);
	COPY_NODE_FIELD(fdw_scan_tlist);
	COPY_NODE_FIELD(fdw_recheck_quals);
	COPY_BITMAPSET_FIELD(fs_relids);
	COPY_SCALAR_FIELD(fsSystemCol);

	return fc_newnode;
}

/*
 * _copyCustomScan
 */
static CustomScan * fc__copyCustomScan(const CustomScan *fc_from)
{
	CustomScan *fc_newnode = makeNode(CustomScan);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyScanFields((const Scan *) fc_from, (Scan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(flags);
	COPY_NODE_FIELD(custom_plans);
	COPY_NODE_FIELD(custom_exprs);
	COPY_NODE_FIELD(custom_private);
	COPY_NODE_FIELD(custom_scan_tlist);
	COPY_BITMAPSET_FIELD(custom_relids);

	/*
	 * 注意：CustomScan 的 method 字段必须是一个指向
	 * 回调函数静态表的指针。因此我们不复制表本身，
	 * 只是引用原始的。
	 */
	COPY_SCALAR_FIELD(methods);

	return fc_newnode;
}

/*
 * CopyJoinFields
 *
 *		此函数复制连接节点的字段。它被所有继承自Join的类的复制函数使用。
 */
static void fc_CopyJoinFields(const Join *fc_from, Join *fc_newnode)
{
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	COPY_SCALAR_FIELD(jointype);
	COPY_SCALAR_FIELD(inner_unique);
	COPY_NODE_FIELD(joinqual);
}


/*
 * _copyJoin
 */
static Join *
fc__copyJoin(const Join *fc_from)
{
	Join	   *fc_newnode = makeNode(Join);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyJoinFields(fc_from, fc_newnode);

	return fc_newnode;
}


/*
 * _copyNestLoop
 */
static NestLoop * fc__copyNestLoop(const NestLoop *fc_from)
{
	NestLoop   *fc_newnode = makeNode(NestLoop);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyJoinFields((const Join *) fc_from, (Join *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(nestParams);

	return fc_newnode;
}


/*
 * _copyMergeJoin
 */
static MergeJoin * fc__copyMergeJoin(const MergeJoin *fc_from)
{
	MergeJoin  *fc_newnode = makeNode(MergeJoin);
	int			fc_numCols;

	/*
	 * 复制节点超类字段
	 */
	fc_CopyJoinFields((const Join *) fc_from, (Join *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(skip_mark_restore);
	COPY_NODE_FIELD(mergeclauses);
	fc_numCols = list_length(fc_from->mergeclauses);
	COPY_POINTER_FIELD(mergeFamilies, fc_numCols * sizeof(Oid));
	COPY_POINTER_FIELD(mergeCollations, fc_numCols * sizeof(Oid));
	COPY_POINTER_FIELD(mergeStrategies, fc_numCols * sizeof(int));
	COPY_POINTER_FIELD(mergeNullsFirst, fc_numCols * sizeof(bool));

	return fc_newnode;
}

/*
 * _copyHashJoin
 */
static HashJoin * fc__copyHashJoin(const HashJoin *fc_from)
{
	HashJoin   *fc_newnode = makeNode(HashJoin);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyJoinFields((const Join *) fc_from, (Join *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(hashclauses);
	COPY_NODE_FIELD(hashoperators);
	COPY_NODE_FIELD(hashcollations);
	COPY_NODE_FIELD(hashkeys);

	return fc_newnode;
}


/*
 * _copyMaterial
 */
static Material * fc__copyMaterial(const Material *fc_from)
{
	Material   *fc_newnode = makeNode(Material);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	return fc_newnode;
}


/*
 * _copyMemoize
 */
static Memoize * fc__copyMemoize(const Memoize *fc_from)
{
	Memoize    *fc_newnode = makeNode(Memoize);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(numKeys);
	COPY_POINTER_FIELD(hashOperators, sizeof(Oid) * fc_from->numKeys);
	COPY_POINTER_FIELD(collations, sizeof(Oid) * fc_from->numKeys);
	COPY_NODE_FIELD(param_exprs);
	COPY_SCALAR_FIELD(singlerow);
	COPY_SCALAR_FIELD(binary_mode);
	COPY_SCALAR_FIELD(est_entries);
	COPY_BITMAPSET_FIELD(keyparamids);

	return fc_newnode;
}


/*
 * CopySortFields
 *
 *		此函数复制 Sort 节点的字段。它被所有从 Sort 继承的类的复制函数使用。
 */
static void fc_CopySortFields(const Sort *fc_from, Sort *fc_newnode)
{
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	COPY_SCALAR_FIELD(numCols);
	COPY_POINTER_FIELD(sortColIdx, fc_from->numCols * sizeof(AttrNumber));
	COPY_POINTER_FIELD(sortOperators, fc_from->numCols * sizeof(Oid));
	COPY_POINTER_FIELD(collations, fc_from->numCols * sizeof(Oid));
	COPY_POINTER_FIELD(nullsFirst, fc_from->numCols * sizeof(bool));
}

/*
 * _copySort
 */
static Sort * fc__copySort(const Sort *fc_from)
{
	Sort	   *fc_newnode = makeNode(Sort);

	/*
	 * 复制节点超类字段
	 */
	fc_CopySortFields(fc_from, fc_newnode);

	return fc_newnode;
}


/*
 * _copyIncrementalSort
 */
static IncrementalSort * fc__copyIncrementalSort(const IncrementalSort *fc_from)
{
	IncrementalSort *fc_newnode = makeNode(IncrementalSort);

	/*
	 * 复制节点超类字段
	 */
	fc_CopySortFields((const Sort *) fc_from, (Sort *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(nPresortedCols);

	return fc_newnode;
}


/*
 * _copyGroup
 */
static Group * fc__copyGroup(const Group *fc_from)
{
	Group	   *fc_newnode = makeNode(Group);

	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	COPY_SCALAR_FIELD(numCols);
	COPY_POINTER_FIELD(grpColIdx, fc_from->numCols * sizeof(AttrNumber));
	COPY_POINTER_FIELD(grpOperators, fc_from->numCols * sizeof(Oid));
	COPY_POINTER_FIELD(grpCollations, fc_from->numCols * sizeof(Oid));

	return fc_newnode;
}

/*
 * _copyAgg
 */
static Agg * fc__copyAgg(const Agg *fc_from)
{
	Agg		   *fc_newnode = makeNode(Agg);

	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	COPY_SCALAR_FIELD(aggstrategy);
	COPY_SCALAR_FIELD(aggsplit);
	COPY_SCALAR_FIELD(numCols);
	COPY_POINTER_FIELD(grpColIdx, fc_from->numCols * sizeof(AttrNumber));
	COPY_POINTER_FIELD(grpOperators, fc_from->numCols * sizeof(Oid));
	COPY_POINTER_FIELD(grpCollations, fc_from->numCols * sizeof(Oid));
	COPY_SCALAR_FIELD(numGroups);
	COPY_SCALAR_FIELD(transitionSpace);
	COPY_BITMAPSET_FIELD(aggParams);
	COPY_NODE_FIELD(groupingSets);
	COPY_NODE_FIELD(chain);

	return fc_newnode;
}

/*
 * _copyWindowAgg
 */
static WindowAgg * fc__copyWindowAgg(const WindowAgg *fc_from)
{
	WindowAgg  *fc_newnode = makeNode(WindowAgg);

	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	COPY_SCALAR_FIELD(winref);
	COPY_SCALAR_FIELD(partNumCols);
	COPY_POINTER_FIELD(partColIdx, fc_from->partNumCols * sizeof(AttrNumber));
	COPY_POINTER_FIELD(partOperators, fc_from->partNumCols * sizeof(Oid));
	COPY_POINTER_FIELD(partCollations, fc_from->partNumCols * sizeof(Oid));
	COPY_SCALAR_FIELD(ordNumCols);
	COPY_POINTER_FIELD(ordColIdx, fc_from->ordNumCols * sizeof(AttrNumber));
	COPY_POINTER_FIELD(ordOperators, fc_from->ordNumCols * sizeof(Oid));
	COPY_POINTER_FIELD(ordCollations, fc_from->ordNumCols * sizeof(Oid));
	COPY_SCALAR_FIELD(frameOptions);
	COPY_NODE_FIELD(startOffset);
	COPY_NODE_FIELD(endOffset);
	COPY_NODE_FIELD(runCondition);
	COPY_NODE_FIELD(runConditionOrig);
	COPY_SCALAR_FIELD(startInRangeFunc);
	COPY_SCALAR_FIELD(endInRangeFunc);
	COPY_SCALAR_FIELD(inRangeColl);
	COPY_SCALAR_FIELD(inRangeAsc);
	COPY_SCALAR_FIELD(inRangeNullsFirst);
	COPY_SCALAR_FIELD(topWindow);

	return fc_newnode;
}

/*
 * _copyUnique
 */
static Unique * fc__copyUnique(const Unique *fc_from)
{
	Unique	   *fc_newnode = makeNode(Unique);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(numCols);
	COPY_POINTER_FIELD(uniqColIdx, fc_from->numCols * sizeof(AttrNumber));
	COPY_POINTER_FIELD(uniqOperators, fc_from->numCols * sizeof(Oid));
	COPY_POINTER_FIELD(uniqCollations, fc_from->numCols * sizeof(Oid));

	return fc_newnode;
}

/*
 * _copyHash
 */
static Hash * fc__copyHash(const Hash *fc_from)
{
	Hash	   *fc_newnode = makeNode(Hash);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(hashkeys);
	COPY_SCALAR_FIELD(skewTable);
	COPY_SCALAR_FIELD(skewColumn);
	COPY_SCALAR_FIELD(skewInherit);
	COPY_SCALAR_FIELD(rows_total);

	return fc_newnode;
}

/*
 * _copySetOp
 */
static SetOp * fc__copySetOp(const SetOp *fc_from)
{
	SetOp	   *fc_newnode = makeNode(SetOp);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_SCALAR_FIELD(cmd);
	COPY_SCALAR_FIELD(strategy);
	COPY_SCALAR_FIELD(numCols);
	COPY_POINTER_FIELD(dupColIdx, fc_from->numCols * sizeof(AttrNumber));
	COPY_POINTER_FIELD(dupOperators, fc_from->numCols * sizeof(Oid));
	COPY_POINTER_FIELD(dupCollations, fc_from->numCols * sizeof(Oid));
	COPY_SCALAR_FIELD(flagColIdx);
	COPY_SCALAR_FIELD(firstFlag);
	COPY_SCALAR_FIELD(numGroups);

	return fc_newnode;
}

/*
 * _copyLockRows
 */
static LockRows * fc__copyLockRows(const LockRows *fc_from)
{
	LockRows   *fc_newnode = makeNode(LockRows);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(rowMarks);
	COPY_SCALAR_FIELD(epqParam);

	return fc_newnode;
}

/*
 * _copyLimit
 */
static Limit * fc__copyLimit(const Limit *fc_from)
{
	Limit	   *fc_newnode = makeNode(Limit);

	/*
	 * 复制节点超类字段
	 */
	fc_CopyPlanFields((const Plan *) fc_from, (Plan *) fc_newnode);

	/*
	 * 复制节点的其余部分
	 */
	COPY_NODE_FIELD(limitOffset);
	COPY_NODE_FIELD(limitCount);
	COPY_SCALAR_FIELD(limitOption);
	COPY_SCALAR_FIELD(uniqNumCols);
	COPY_POINTER_FIELD(uniqColIdx, fc_from->uniqNumCols * sizeof(AttrNumber));
	COPY_POINTER_FIELD(uniqOperators, fc_from->uniqNumCols * sizeof(Oid));
	COPY_POINTER_FIELD(uniqCollations, fc_from->uniqNumCols * sizeof(Oid));

	return fc_newnode;
}

/*
 * _copyNestLoopParam
 */
static NestLoopParam *
fc__copyNestLoopParam(const NestLoopParam *fc_from)
{
	NestLoopParam *fc_newnode = makeNode(NestLoopParam);

	COPY_SCALAR_FIELD(paramno);
	COPY_NODE_FIELD(paramval);

	return fc_newnode;
}

/*
 * _copyPlanRowMark
 */
static PlanRowMark *
fc__copyPlanRowMark(const PlanRowMark *fc_from)
{
	PlanRowMark *fc_newnode = makeNode(PlanRowMark);

	COPY_SCALAR_FIELD(rti);
	COPY_SCALAR_FIELD(prti);
	COPY_SCALAR_FIELD(rowmarkId);
	COPY_SCALAR_FIELD(markType);
	COPY_SCALAR_FIELD(allMarkTypes);
	COPY_SCALAR_FIELD(strength);
	COPY_SCALAR_FIELD(waitPolicy);
	COPY_SCALAR_FIELD(isParent);

	return fc_newnode;
}

static PartitionPruneInfo *
fc__copyPartitionPruneInfo(const PartitionPruneInfo *fc_from)
{
	PartitionPruneInfo *fc_newnode = makeNode(PartitionPruneInfo);

	COPY_NODE_FIELD(prune_infos);
	COPY_BITMAPSET_FIELD(other_subplans);

	return fc_newnode;
}

static PartitionedRelPruneInfo *
fc__copyPartitionedRelPruneInfo(const PartitionedRelPruneInfo *fc_from)
{
	PartitionedRelPruneInfo *fc_newnode = makeNode(PartitionedRelPruneInfo);

	COPY_SCALAR_FIELD(rtindex);
	COPY_BITMAPSET_FIELD(present_parts);
	COPY_SCALAR_FIELD(nparts);
	COPY_POINTER_FIELD(subplan_map, fc_from->nparts * sizeof(int));
	COPY_POINTER_FIELD(subpart_map, fc_from->nparts * sizeof(int));
	COPY_POINTER_FIELD(relid_map, fc_from->nparts * sizeof(Oid));
	COPY_NODE_FIELD(initial_pruning_steps);
	COPY_NODE_FIELD(exec_pruning_steps);
	COPY_BITMAPSET_FIELD(execparamids);

	return fc_newnode;
}

/*
 * _copyPartitionPruneStepOp
 */
static PartitionPruneStepOp *
fc__copyPartitionPruneStepOp(const PartitionPruneStepOp *fc_from)
{
	PartitionPruneStepOp *fc_newnode = makeNode(PartitionPruneStepOp);

	COPY_SCALAR_FIELD(step.step_id);
	COPY_SCALAR_FIELD(opstrategy);
	COPY_NODE_FIELD(exprs);
	COPY_NODE_FIELD(cmpfns);
	COPY_BITMAPSET_FIELD(nullkeys);

	return fc_newnode;
}

/*
 * _copyPartitionPruneStepCombine
 */
static PartitionPruneStepCombine *
fc__copyPartitionPruneStepCombine(const PartitionPruneStepCombine *fc_from)
{
	PartitionPruneStepCombine *fc_newnode = makeNode(PartitionPruneStepCombine);

	COPY_SCALAR_FIELD(step.step_id);
	COPY_SCALAR_FIELD(combineOp);
	COPY_NODE_FIELD(source_stepids);

	return fc_newnode;
}

/*
 * _copyPlanInvalItem
 */
static PlanInvalItem *
fc__copyPlanInvalItem(const PlanInvalItem *fc_from)
{
	PlanInvalItem *fc_newnode = makeNode(PlanInvalItem);

	COPY_SCALAR_FIELD(cacheId);
	COPY_SCALAR_FIELD(hashValue);

	return fc_newnode;
}

/* ****************************************************************
 *					   primnodes.h 复制函数
 * ****************************************************************
 */

/*
 * _copyAlias
 */
static Alias *
fc__copyAlias(const Alias *fc_from)
{
	Alias	   *fc_newnode = makeNode(Alias);

	COPY_STRING_FIELD(aliasname);
	COPY_NODE_FIELD(colnames);

	return fc_newnode;
}

/*
 * _copyRangeVar
 */
static RangeVar *
fc__copyRangeVar(const RangeVar *fc_from)
{
	RangeVar   *fc_newnode = makeNode(RangeVar);

	COPY_STRING_FIELD(catalogname);
	COPY_STRING_FIELD(schemaname);
	COPY_STRING_FIELD(relname);
	COPY_SCALAR_FIELD(inh);
	COPY_SCALAR_FIELD(relpersistence);
	COPY_NODE_FIELD(alias);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyTableFunc
 */
static TableFunc *
fc__copyTableFunc(const TableFunc *fc_from)
{
	TableFunc  *fc_newnode = makeNode(TableFunc);

	COPY_NODE_FIELD(ns_uris);
	COPY_NODE_FIELD(ns_names);
	COPY_NODE_FIELD(docexpr);
	COPY_NODE_FIELD(rowexpr);
	COPY_NODE_FIELD(colnames);
	COPY_NODE_FIELD(coltypes);
	COPY_NODE_FIELD(coltypmods);
	COPY_NODE_FIELD(colcollations);
	COPY_NODE_FIELD(colexprs);
	COPY_NODE_FIELD(coldefexprs);
	COPY_BITMAPSET_FIELD(notnulls);
	COPY_SCALAR_FIELD(ordinalitycol);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyIntoClause
 */
static IntoClause *
fc__copyIntoClause(const IntoClause *fc_from)
{
	IntoClause *fc_newnode = makeNode(IntoClause);

	COPY_NODE_FIELD(rel);
	COPY_NODE_FIELD(colNames);
	COPY_STRING_FIELD(accessMethod);
	COPY_NODE_FIELD(options);
	COPY_SCALAR_FIELD(onCommit);
	COPY_STRING_FIELD(tableSpaceName);
	COPY_NODE_FIELD(viewQuery);
	COPY_SCALAR_FIELD(skipData);

	return fc_newnode;
}

/*
 * 我们不需要 _copyExpr，因为 Expr 是一个抽象超类型，永远不应该被实例化。此外，由于它没有除了 NodeTag 之外的公共字段，因此没有必要为提取公共字段的复制编写辅助例程...
 */

/*
 * _copyVar
 */
static Var * fc__copyVar(const Var *fc_from)
{
	Var		   *fc_newnode = makeNode(Var);

	COPY_SCALAR_FIELD(varno);
	COPY_SCALAR_FIELD(varattno);
	COPY_SCALAR_FIELD(vartype);
	COPY_SCALAR_FIELD(vartypmod);
	COPY_SCALAR_FIELD(varcollid);
	COPY_SCALAR_FIELD(varlevelsup);
	COPY_SCALAR_FIELD(varnosyn);
	COPY_SCALAR_FIELD(varattnosyn);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyConst
 */
static Const * fc__copyConst(const Const *fc_from)
{
	Const	   *fc_newnode = makeNode(Const);

	COPY_SCALAR_FIELD(consttype);
	COPY_SCALAR_FIELD(consttypmod);
	COPY_SCALAR_FIELD(constcollid);
	COPY_SCALAR_FIELD(constlen);

	if (fc_from->constbyval || fc_from->constisnull)
	{
		/*
		 * 按值传递，因此只需复制 datum。如果值为 null，亦不要试图复制结构！
		 */
		fc_newnode->constvalue = fc_from->constvalue;
	}
	else
	{
		/*
		 * 按引用传递。我们需要一个 palloc'd 拷贝。
		 */
		fc_newnode->constvalue = datumCopy(fc_from->constvalue,
										fc_from->constbyval,
										fc_from->constlen);
	}

	COPY_SCALAR_FIELD(constisnull);
	COPY_SCALAR_FIELD(constbyval);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyParam
 */
static Param *
fc__copyParam(const Param *fc_from)
{
	Param	   *fc_newnode = makeNode(Param);

	COPY_SCALAR_FIELD(paramkind);
	COPY_SCALAR_FIELD(paramid);
	COPY_SCALAR_FIELD(paramtype);
	COPY_SCALAR_FIELD(paramtypmod);
	COPY_SCALAR_FIELD(paramcollid);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyAggref
 */
static Aggref *
fc__copyAggref(const Aggref *fc_from)
{
	Aggref	   *fc_newnode = makeNode(Aggref);

	COPY_SCALAR_FIELD(aggfnoid);
	COPY_SCALAR_FIELD(aggtype);
	COPY_SCALAR_FIELD(aggcollid);
	COPY_SCALAR_FIELD(inputcollid);
	COPY_SCALAR_FIELD(aggtranstype);
	COPY_NODE_FIELD(aggargtypes);
	COPY_NODE_FIELD(aggdirectargs);
	COPY_NODE_FIELD(args);
	COPY_NODE_FIELD(aggorder);
	COPY_NODE_FIELD(aggdistinct);
	COPY_NODE_FIELD(aggfilter);
	COPY_SCALAR_FIELD(aggstar);
	COPY_SCALAR_FIELD(aggvariadic);
	COPY_SCALAR_FIELD(aggkind);
	COPY_SCALAR_FIELD(agglevelsup);
	COPY_SCALAR_FIELD(aggsplit);
	COPY_SCALAR_FIELD(aggno);
	COPY_SCALAR_FIELD(aggtransno);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyGroupingFunc
 */
static GroupingFunc *
fc__copyGroupingFunc(const GroupingFunc *fc_from)
{
	GroupingFunc *fc_newnode = makeNode(GroupingFunc);

	COPY_NODE_FIELD(args);
	COPY_NODE_FIELD(refs);
	COPY_NODE_FIELD(cols);
	COPY_SCALAR_FIELD(agglevelsup);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyWindowFunc
 */
static WindowFunc *
fc__copyWindowFunc(const WindowFunc *fc_from)
{
	WindowFunc *fc_newnode = makeNode(WindowFunc);

	COPY_SCALAR_FIELD(winfnoid);
	COPY_SCALAR_FIELD(wintype);
	COPY_SCALAR_FIELD(wincollid);
	COPY_SCALAR_FIELD(inputcollid);
	COPY_NODE_FIELD(args);
	COPY_NODE_FIELD(aggfilter);
	COPY_SCALAR_FIELD(winref);
	COPY_SCALAR_FIELD(winstar);
	COPY_SCALAR_FIELD(winagg);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copySubscriptingRef
 */
static SubscriptingRef *
fc__copySubscriptingRef(const SubscriptingRef *fc_from)
{
	SubscriptingRef *fc_newnode = makeNode(SubscriptingRef);

	COPY_SCALAR_FIELD(refcontainertype);
	COPY_SCALAR_FIELD(refelemtype);
	COPY_SCALAR_FIELD(refrestype);
	COPY_SCALAR_FIELD(reftypmod);
	COPY_SCALAR_FIELD(refcollid);
	COPY_NODE_FIELD(refupperindexpr);
	COPY_NODE_FIELD(reflowerindexpr);
	COPY_NODE_FIELD(refexpr);
	COPY_NODE_FIELD(refassgnexpr);

	return fc_newnode;
}

/*
 * _copyFuncExpr
 */
static FuncExpr *
fc__copyFuncExpr(const FuncExpr *fc_from)
{
	FuncExpr   *fc_newnode = makeNode(FuncExpr);

	COPY_SCALAR_FIELD(funcid);
	COPY_SCALAR_FIELD(funcresulttype);
	COPY_SCALAR_FIELD(funcretset);
	COPY_SCALAR_FIELD(funcvariadic);
	COPY_SCALAR_FIELD(funcformat);
	COPY_SCALAR_FIELD(funccollid);
	COPY_SCALAR_FIELD(inputcollid);
	COPY_NODE_FIELD(args);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyNamedArgExpr *
 */
static NamedArgExpr *
fc__copyNamedArgExpr(const NamedArgExpr *fc_from)
{
	NamedArgExpr *fc_newnode = makeNode(NamedArgExpr);

	COPY_NODE_FIELD(arg);
	COPY_STRING_FIELD(name);
	COPY_SCALAR_FIELD(argnumber);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyOpExpr
 */
static OpExpr *
fc__copyOpExpr(const OpExpr *fc_from)
{
	OpExpr	   *fc_newnode = makeNode(OpExpr);

	COPY_SCALAR_FIELD(opno);
	COPY_SCALAR_FIELD(opfuncid);
	COPY_SCALAR_FIELD(opresulttype);
	COPY_SCALAR_FIELD(opretset);
	COPY_SCALAR_FIELD(opcollid);
	COPY_SCALAR_FIELD(inputcollid);
	COPY_NODE_FIELD(args);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyDistinctExpr (同 OpExpr)
 */
static DistinctExpr *
fc__copyDistinctExpr(const DistinctExpr *fc_from)
{
	DistinctExpr *fc_newnode = makeNode(DistinctExpr);

	COPY_SCALAR_FIELD(opno);
	COPY_SCALAR_FIELD(opfuncid);
	COPY_SCALAR_FIELD(opresulttype);
	COPY_SCALAR_FIELD(opretset);
	COPY_SCALAR_FIELD(opcollid);
	COPY_SCALAR_FIELD(inputcollid);
	COPY_NODE_FIELD(args);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyNullIfExpr (同 OpExpr)
 */
static NullIfExpr *
fc__copyNullIfExpr(const NullIfExpr *fc_from)
{
	NullIfExpr *fc_newnode = makeNode(NullIfExpr);

	COPY_SCALAR_FIELD(opno);
	COPY_SCALAR_FIELD(opfuncid);
	COPY_SCALAR_FIELD(opresulttype);
	COPY_SCALAR_FIELD(opretset);
	COPY_SCALAR_FIELD(opcollid);
	COPY_SCALAR_FIELD(inputcollid);
	COPY_NODE_FIELD(args);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyScalarArrayOpExpr
 */
static ScalarArrayOpExpr *
fc__copyScalarArrayOpExpr(const ScalarArrayOpExpr *fc_from)
{
	ScalarArrayOpExpr *fc_newnode = makeNode(ScalarArrayOpExpr);

	COPY_SCALAR_FIELD(opno);
	COPY_SCALAR_FIELD(opfuncid);
	COPY_SCALAR_FIELD(hashfuncid);
	COPY_SCALAR_FIELD(negfuncid);
	COPY_SCALAR_FIELD(useOr);
	COPY_SCALAR_FIELD(inputcollid);
	COPY_NODE_FIELD(args);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyBoolExpr
 */
static BoolExpr *
fc__copyBoolExpr(const BoolExpr *fc_from)
{
	BoolExpr   *fc_newnode = makeNode(BoolExpr);

	COPY_SCALAR_FIELD(boolop);
	COPY_NODE_FIELD(args);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copySubLink
 */
static SubLink *
fc__copySubLink(const SubLink *fc_from)
{
	SubLink    *fc_newnode = makeNode(SubLink);

	COPY_SCALAR_FIELD(subLinkType);
	COPY_SCALAR_FIELD(subLinkId);
	COPY_NODE_FIELD(testexpr);
	COPY_NODE_FIELD(operName);
	COPY_NODE_FIELD(subselect);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copySubPlan
 */
static SubPlan *
fc__copySubPlan(const SubPlan *fc_from)
{
	SubPlan    *fc_newnode = makeNode(SubPlan);

	COPY_SCALAR_FIELD(subLinkType);
	COPY_NODE_FIELD(testexpr);
	COPY_NODE_FIELD(paramIds);
	COPY_SCALAR_FIELD(plan_id);
	COPY_STRING_FIELD(plan_name);
	COPY_SCALAR_FIELD(firstColType);
	COPY_SCALAR_FIELD(firstColTypmod);
	COPY_SCALAR_FIELD(firstColCollation);
	COPY_SCALAR_FIELD(useHashTable);
	COPY_SCALAR_FIELD(unknownEqFalse);
	COPY_SCALAR_FIELD(parallel_safe);
	COPY_NODE_FIELD(setParam);
	COPY_NODE_FIELD(parParam);
	COPY_NODE_FIELD(args);
	COPY_SCALAR_FIELD(startup_cost);
	COPY_SCALAR_FIELD(per_call_cost);

	return fc_newnode;
}

/*
 * _copyAlternativeSubPlan
 */
static AlternativeSubPlan *
fc__copyAlternativeSubPlan(const AlternativeSubPlan *fc_from)
{
	AlternativeSubPlan *fc_newnode = makeNode(AlternativeSubPlan);

	COPY_NODE_FIELD(subplans);

	return fc_newnode;
}

/*
 * _copyFieldSelect
 */
static FieldSelect *
fc__copyFieldSelect(const FieldSelect *fc_from)
{
	FieldSelect *fc_newnode = makeNode(FieldSelect);

	COPY_NODE_FIELD(arg);
	COPY_SCALAR_FIELD(fieldnum);
	COPY_SCALAR_FIELD(resulttype);
	COPY_SCALAR_FIELD(resulttypmod);
	COPY_SCALAR_FIELD(resultcollid);

	return fc_newnode;
}

/*
 * _copyFieldStore
 */
static FieldStore *
fc__copyFieldStore(const FieldStore *fc_from)
{
	FieldStore *fc_newnode = makeNode(FieldStore);

	COPY_NODE_FIELD(arg);
	COPY_NODE_FIELD(newvals);
	COPY_NODE_FIELD(fieldnums);
	COPY_SCALAR_FIELD(resulttype);

	return fc_newnode;
}

/*
 * _copyRelabelType
 */
static RelabelType *
fc__copyRelabelType(const RelabelType *fc_from)
{
	RelabelType *fc_newnode = makeNode(RelabelType);

	COPY_NODE_FIELD(arg);
	COPY_SCALAR_FIELD(resulttype);
	COPY_SCALAR_FIELD(resulttypmod);
	COPY_SCALAR_FIELD(resultcollid);
	COPY_SCALAR_FIELD(relabelformat);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyCoerceViaIO
 */
static CoerceViaIO *
fc__copyCoerceViaIO(const CoerceViaIO *fc_from)
{
	CoerceViaIO *fc_newnode = makeNode(CoerceViaIO);

	COPY_NODE_FIELD(arg);
	COPY_SCALAR_FIELD(resulttype);
	COPY_SCALAR_FIELD(resultcollid);
	COPY_SCALAR_FIELD(coerceformat);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyArrayCoerceExpr
 */
static ArrayCoerceExpr *
fc__copyArrayCoerceExpr(const ArrayCoerceExpr *fc_from)
{
	ArrayCoerceExpr *fc_newnode = makeNode(ArrayCoerceExpr);

	COPY_NODE_FIELD(arg);
	COPY_NODE_FIELD(elemexpr);
	COPY_SCALAR_FIELD(resulttype);
	COPY_SCALAR_FIELD(resulttypmod);
	COPY_SCALAR_FIELD(resultcollid);
	COPY_SCALAR_FIELD(coerceformat);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyConvertRowtypeExpr
 */
static ConvertRowtypeExpr *
fc__copyConvertRowtypeExpr(const ConvertRowtypeExpr *fc_from)
{
	ConvertRowtypeExpr *fc_newnode = makeNode(ConvertRowtypeExpr);

	COPY_NODE_FIELD(arg);
	COPY_SCALAR_FIELD(resulttype);
	COPY_SCALAR_FIELD(convertformat);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyCollateExpr
 */
static CollateExpr *
fc__copyCollateExpr(const CollateExpr *fc_from)
{
	CollateExpr *fc_newnode = makeNode(CollateExpr);

	COPY_NODE_FIELD(arg);
	COPY_SCALAR_FIELD(collOid);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyCaseExpr
 */
static CaseExpr *
fc__copyCaseExpr(const CaseExpr *fc_from)
{
	CaseExpr   *fc_newnode = makeNode(CaseExpr);

	COPY_SCALAR_FIELD(casetype);
	COPY_SCALAR_FIELD(casecollid);
	COPY_NODE_FIELD(arg);
	COPY_NODE_FIELD(args);
	COPY_NODE_FIELD(defresult);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyCaseWhen
 */
static CaseWhen *
fc__copyCaseWhen(const CaseWhen *fc_from)
{
	CaseWhen   *fc_newnode = makeNode(CaseWhen);

	COPY_NODE_FIELD(expr);
	COPY_NODE_FIELD(result);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyCaseTestExpr
 */
static CaseTestExpr *
fc__copyCaseTestExpr(const CaseTestExpr *fc_from)
{
	CaseTestExpr *fc_newnode = makeNode(CaseTestExpr);

	COPY_SCALAR_FIELD(typeId);
	COPY_SCALAR_FIELD(typeMod);
	COPY_SCALAR_FIELD(collation);

	return fc_newnode;
}

/*
 * _copyArrayExpr
 */
static ArrayExpr *
fc__copyArrayExpr(const ArrayExpr *fc_from)
{
	ArrayExpr  *fc_newnode = makeNode(ArrayExpr);

	COPY_SCALAR_FIELD(array_typeid);
	COPY_SCALAR_FIELD(array_collid);
	COPY_SCALAR_FIELD(element_typeid);
	COPY_NODE_FIELD(elements);
	COPY_SCALAR_FIELD(multidims);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyRowExpr
 */
static RowExpr * fc__copyRowExpr(const RowExpr *fc_from)
{
	RowExpr    *fc_newnode = makeNode(RowExpr);

	COPY_NODE_FIELD(args);
	COPY_SCALAR_FIELD(row_typeid);
	COPY_SCALAR_FIELD(row_format);
	COPY_NODE_FIELD(colnames);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyRowCompareExpr
 */
static RowCompareExpr *
fc__copyRowCompareExpr(const RowCompareExpr *fc_from)
{
	RowCompareExpr *fc_newnode = makeNode(RowCompareExpr);

	COPY_SCALAR_FIELD(rctype);
	COPY_NODE_FIELD(opnos);
	COPY_NODE_FIELD(opfamilies);
	COPY_NODE_FIELD(inputcollids);
	COPY_NODE_FIELD(largs);
	COPY_NODE_FIELD(rargs);

	return fc_newnode;
}

/*
 * _copyCoalesceExpr
 */
static CoalesceExpr *
fc__copyCoalesceExpr(const CoalesceExpr *fc_from)
{
	CoalesceExpr *fc_newnode = makeNode(CoalesceExpr);

	COPY_SCALAR_FIELD(coalescetype);
	COPY_SCALAR_FIELD(coalescecollid);
	COPY_NODE_FIELD(args);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyMinMaxExpr
 */
static MinMaxExpr *
fc__copyMinMaxExpr(const MinMaxExpr *fc_from)
{
	MinMaxExpr *fc_newnode = makeNode(MinMaxExpr);

	COPY_SCALAR_FIELD(minmaxtype);
	COPY_SCALAR_FIELD(minmaxcollid);
	COPY_SCALAR_FIELD(inputcollid);
	COPY_SCALAR_FIELD(op);
	COPY_NODE_FIELD(args);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copySQLValueFunction
 */
static SQLValueFunction *
fc__copySQLValueFunction(const SQLValueFunction *fc_from)
{
	SQLValueFunction *fc_newnode = makeNode(SQLValueFunction);

	COPY_SCALAR_FIELD(op);
	COPY_SCALAR_FIELD(type);
	COPY_SCALAR_FIELD(typmod);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyXmlExpr
 */
static XmlExpr *
fc__copyXmlExpr(const XmlExpr *fc_from)
{
	XmlExpr    *fc_newnode = makeNode(XmlExpr);

	COPY_SCALAR_FIELD(op);
	COPY_STRING_FIELD(name);
	COPY_NODE_FIELD(named_args);
	COPY_NODE_FIELD(arg_names);
	COPY_NODE_FIELD(args);
	COPY_SCALAR_FIELD(xmloption);
	COPY_SCALAR_FIELD(type);
	COPY_SCALAR_FIELD(typmod);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyNullTest
 */
static NullTest *
fc__copyNullTest(const NullTest *fc_from)
{
	NullTest   *fc_newnode = makeNode(NullTest);

	COPY_NODE_FIELD(arg);
	COPY_SCALAR_FIELD(nulltesttype);
	COPY_SCALAR_FIELD(argisrow);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyBooleanTest
 */
static BooleanTest *
fc__copyBooleanTest(const BooleanTest *fc_from)
{
	BooleanTest *fc_newnode = makeNode(BooleanTest);

	COPY_NODE_FIELD(arg);
	COPY_SCALAR_FIELD(booltesttype);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyCoerceToDomain
 */
static CoerceToDomain *
fc__copyCoerceToDomain(const CoerceToDomain *fc_from)
{
	CoerceToDomain *fc_newnode = makeNode(CoerceToDomain);

	COPY_NODE_FIELD(arg);
	COPY_SCALAR_FIELD(resulttype);
	COPY_SCALAR_FIELD(resulttypmod);
	COPY_SCALAR_FIELD(resultcollid);
	COPY_SCALAR_FIELD(coercionformat);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyCoerceToDomainValue
 */
static CoerceToDomainValue *
fc__copyCoerceToDomainValue(const CoerceToDomainValue *fc_from)
{
	CoerceToDomainValue *fc_newnode = makeNode(CoerceToDomainValue);

	COPY_SCALAR_FIELD(typeId);
	COPY_SCALAR_FIELD(typeMod);
	COPY_SCALAR_FIELD(collation);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copySetToDefault
 */
static SetToDefault *
fc__copySetToDefault(const SetToDefault *fc_from)
{
	SetToDefault *fc_newnode = makeNode(SetToDefault);

	COPY_SCALAR_FIELD(typeId);
	COPY_SCALAR_FIELD(typeMod);
	COPY_SCALAR_FIELD(collation);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

/*
 * _copyCurrentOfExpr
 */
static CurrentOfExpr *
fc__copyCurrentOfExpr(const CurrentOfExpr *fc_from)
{
	CurrentOfExpr *fc_newnode = makeNode(CurrentOfExpr);

	COPY_SCALAR_FIELD(cvarno);
	COPY_STRING_FIELD(cursor_name);
	COPY_SCALAR_FIELD(cursor_param);

	return fc_newnode;
}

 /*
  * _copyNextValueExpr
  */
static NextValueExpr *
fc__copyNextValueExpr(const NextValueExpr *fc_from)
{
	NextValueExpr *fc_newnode = makeNode(NextValueExpr);

	COPY_SCALAR_FIELD(seqid);
	COPY_SCALAR_FIELD(typeId);

	return fc_newnode;
}

/*
 * _copyInferenceElem
 */
static InferenceElem *
fc__copyInferenceElem(const InferenceElem *fc_from)
{
	InferenceElem *fc_newnode = makeNode(InferenceElem);

	COPY_NODE_FIELD(expr);
	COPY_SCALAR_FIELD(infercollid);
	COPY_SCALAR_FIELD(inferopclass);

	return fc_newnode;
}

/*
 * _copyTargetEntry
 */
static TargetEntry * fc__copyTargetEntry(const TargetEntry *fc_from)
{
	TargetEntry *fc_newnode = makeNode(TargetEntry);

	COPY_NODE_FIELD(expr);
	COPY_SCALAR_FIELD(resno);
	COPY_STRING_FIELD(resname);
	COPY_SCALAR_FIELD(ressortgroupref);
	COPY_SCALAR_FIELD(resorigtbl);
	COPY_SCALAR_FIELD(resorigcol);
	COPY_SCALAR_FIELD(resjunk);

	return fc_newnode;
}

/*
 * _copyRangeTblRef
 */
static RangeTblRef *
fc__copyRangeTblRef(const RangeTblRef *fc_from)
{
	RangeTblRef *fc_newnode = makeNode(RangeTblRef);

	COPY_SCALAR_FIELD(rtindex);

	return fc_newnode;
}

/*
 * _copyJoinExpr
 */
static JoinExpr *
fc__copyJoinExpr(const JoinExpr *fc_from)
{
	JoinExpr   *fc_newnode = makeNode(JoinExpr);

	COPY_SCALAR_FIELD(jointype);
	COPY_SCALAR_FIELD(isNatural);
	COPY_NODE_FIELD(larg);
	COPY_NODE_FIELD(rarg);
	COPY_NODE_FIELD(usingClause);
	COPY_NODE_FIELD(join_using_alias);
	COPY_NODE_FIELD(quals);
	COPY_NODE_FIELD(alias);
	COPY_SCALAR_FIELD(rtindex);

	return fc_newnode;
}

/*
 * _copyFromExpr
 */
static FromExpr *
fc__copyFromExpr(const FromExpr *fc_from)
{
	FromExpr   *fc_newnode = makeNode(FromExpr);

	COPY_NODE_FIELD(fromlist);
	COPY_NODE_FIELD(quals);

	return fc_newnode;
}

/*
 * _copyOnConflictExpr
 */
static OnConflictExpr * fc__copyOnConflictExpr(const OnConflictExpr *fc_from)
{
	OnConflictExpr *fc_newnode = makeNode(OnConflictExpr);

	COPY_SCALAR_FIELD(action);
	COPY_NODE_FIELD(arbiterElems);
	COPY_NODE_FIELD(arbiterWhere);
	COPY_SCALAR_FIELD(constraint);
	COPY_NODE_FIELD(onConflictSet);
	COPY_NODE_FIELD(onConflictWhere);
	COPY_SCALAR_FIELD(exclRelIndex);
	COPY_NODE_FIELD(exclRelTlist);

	return fc_newnode;
}

/* ****************************************************************
 *						pathnodes.h 复制函数
 *
 * 我们不支持复制 RelOptInfo、IndexOptInfo 或 Path 节点。
 * 不过，有一些附属结构体是值得复制的。
 * ****************************************************************
 */

/*
 * _copyPathKey
 */
static PathKey * fc__copyPathKey(const PathKey *fc_from)
{
	PathKey    *fc_newnode = makeNode(PathKey);

	/* 等价类永远不会被移动，因此只需浅拷贝指针 */
	COPY_SCALAR_FIELD(pk_eclass);
	COPY_SCALAR_FIELD(pk_opfamily);
	COPY_SCALAR_FIELD(pk_strategy);
	COPY_SCALAR_FIELD(pk_nulls_first);

	return fc_newnode;
}

/*
 * _copyRestrictInfo
 */
static RestrictInfo * fc__copyRestrictInfo(const RestrictInfo *fc_from)
{
	RestrictInfo *fc_newnode = makeNode(RestrictInfo);

	COPY_NODE_FIELD(clause);
	COPY_SCALAR_FIELD(is_pushed_down);
	COPY_SCALAR_FIELD(outerjoin_delayed);
	COPY_SCALAR_FIELD(can_join);
	COPY_SCALAR_FIELD(pseudoconstant);
	COPY_SCALAR_FIELD(leakproof);
	COPY_SCALAR_FIELD(has_volatile);
	COPY_SCALAR_FIELD(security_level);
	COPY_BITMAPSET_FIELD(clause_relids);
	COPY_BITMAPSET_FIELD(required_relids);
	COPY_BITMAPSET_FIELD(outer_relids);
	COPY_BITMAPSET_FIELD(nullable_relids);
	COPY_BITMAPSET_FIELD(left_relids);
	COPY_BITMAPSET_FIELD(right_relids);
	COPY_NODE_FIELD(orclause);
	/* 等价类永远不会被复制，因此浅拷贝指针 */
	COPY_SCALAR_FIELD(parent_ec);
	COPY_SCALAR_FIELD(eval_cost);
	COPY_SCALAR_FIELD(norm_selec);
	COPY_SCALAR_FIELD(outer_selec);
	COPY_NODE_FIELD(mergeopfamilies);
	/* 等价类永远不会被复制，因此浅拷贝指针 */
	COPY_SCALAR_FIELD(left_ec);
	COPY_SCALAR_FIELD(right_ec);
	COPY_SCALAR_FIELD(left_em);
	COPY_SCALAR_FIELD(right_em);
	/* MergeScanSelCache 不是一个节点，所以很难复制；只需重置缓存 */
	fc_newnode->scansel_cache = NIL;
	COPY_SCALAR_FIELD(outer_is_left);
	COPY_SCALAR_FIELD(hashjoinoperator);
	COPY_SCALAR_FIELD(left_bucketsize);
	COPY_SCALAR_FIELD(right_bucketsize);
	COPY_SCALAR_FIELD(left_mcvfreq);
	COPY_SCALAR_FIELD(right_mcvfreq);
	COPY_SCALAR_FIELD(left_hasheqoperator);
	COPY_SCALAR_FIELD(right_hasheqoperator);

	return fc_newnode;
}

/*
 * _copyPlaceHolderVar
 */
static PlaceHolderVar *
fc__copyPlaceHolderVar(const PlaceHolderVar *fc_from)
{
	PlaceHolderVar *fc_newnode = makeNode(PlaceHolderVar);

	COPY_NODE_FIELD(phexpr);
	COPY_BITMAPSET_FIELD(phrels);
	COPY_SCALAR_FIELD(phid);
	COPY_SCALAR_FIELD(phlevelsup);

	return fc_newnode;
}

/*
 * _copySpecialJoinInfo
 */
static SpecialJoinInfo * fc__copySpecialJoinInfo(const SpecialJoinInfo *fc_from)
{
	SpecialJoinInfo *fc_newnode = makeNode(SpecialJoinInfo);

	COPY_BITMAPSET_FIELD(min_lefthand);
	COPY_BITMAPSET_FIELD(min_righthand);
	COPY_BITMAPSET_FIELD(syn_lefthand);
	COPY_BITMAPSET_FIELD(syn_righthand);
	COPY_SCALAR_FIELD(jointype);
	COPY_SCALAR_FIELD(lhs_strict);
	COPY_SCALAR_FIELD(delay_upper_joins);
	COPY_SCALAR_FIELD(semi_can_btree);
	COPY_SCALAR_FIELD(semi_can_hash);
	COPY_NODE_FIELD(semi_operators);
	COPY_NODE_FIELD(semi_rhs_exprs);

	return fc_newnode;
}

/*
 * _copyAppendRelInfo
 */
static AppendRelInfo *
fc__copyAppendRelInfo(const AppendRelInfo *fc_from)
{
	AppendRelInfo *fc_newnode = makeNode(AppendRelInfo);

	COPY_SCALAR_FIELD(parent_relid);
	COPY_SCALAR_FIELD(child_relid);
	COPY_SCALAR_FIELD(parent_reltype);
	COPY_SCALAR_FIELD(child_reltype);
	COPY_NODE_FIELD(translated_vars);
	COPY_SCALAR_FIELD(num_child_cols);
	COPY_POINTER_FIELD(parent_colnos, fc_from->num_child_cols * sizeof(AttrNumber));
	COPY_SCALAR_FIELD(parent_reloid);

	return fc_newnode;
}

/*
 * _copyPlaceHolderInfo
 */
static PlaceHolderInfo *
fc__copyPlaceHolderInfo(const PlaceHolderInfo *fc_from)
{
	PlaceHolderInfo *fc_newnode = makeNode(PlaceHolderInfo);

	COPY_SCALAR_FIELD(phid);
	COPY_NODE_FIELD(ph_var);
	COPY_BITMAPSET_FIELD(ph_eval_at);
	COPY_BITMAPSET_FIELD(ph_lateral);
	COPY_BITMAPSET_FIELD(ph_needed);
	COPY_SCALAR_FIELD(ph_width);

	return fc_newnode;
}

/* ****************************************************************
 *					parsenodes.h 复制函数
 * ****************************************************************
 */

static RangeTblEntry * fc__copyRangeTblEntry(const RangeTblEntry *fc_from)
{
	RangeTblEntry *fc_newnode = makeNode(RangeTblEntry);

	COPY_SCALAR_FIELD(rtekind);
	COPY_SCALAR_FIELD(relid);
	COPY_SCALAR_FIELD(relkind);
	COPY_SCALAR_FIELD(rellockmode);
	COPY_NODE_FIELD(tablesample);
	COPY_NODE_FIELD(subquery);
	COPY_SCALAR_FIELD(security_barrier);
	COPY_SCALAR_FIELD(jointype);
	COPY_SCALAR_FIELD(joinmergedcols);
	COPY_NODE_FIELD(joinaliasvars);
	COPY_NODE_FIELD(joinleftcols);
	COPY_NODE_FIELD(joinrightcols);
	COPY_NODE_FIELD(join_using_alias);
	COPY_NODE_FIELD(functions);
	COPY_SCALAR_FIELD(funcordinality);
	COPY_NODE_FIELD(tablefunc);
	COPY_NODE_FIELD(values_lists);
	COPY_STRING_FIELD(ctename);
	COPY_SCALAR_FIELD(ctelevelsup);
	COPY_SCALAR_FIELD(self_reference);
	COPY_NODE_FIELD(coltypes);
	COPY_NODE_FIELD(coltypmods);
	COPY_NODE_FIELD(colcollations);
	COPY_STRING_FIELD(enrname);
	COPY_SCALAR_FIELD(enrtuples);
	COPY_NODE_FIELD(alias);
	COPY_NODE_FIELD(eref);
	COPY_SCALAR_FIELD(lateral);
	COPY_SCALAR_FIELD(inh);
	COPY_SCALAR_FIELD(inFromCl);
	COPY_SCALAR_FIELD(requiredPerms);
	COPY_SCALAR_FIELD(checkAsUser);
	COPY_BITMAPSET_FIELD(selectedCols);
	COPY_BITMAPSET_FIELD(insertedCols);
	COPY_BITMAPSET_FIELD(updatedCols);
	COPY_BITMAPSET_FIELD(extraUpdatedCols);
	COPY_NODE_FIELD(securityQuals);

	return fc_newnode;
}

static RangeTblFunction *
fc__copyRangeTblFunction(const RangeTblFunction *fc_from)
{
	RangeTblFunction *fc_newnode = makeNode(RangeTblFunction);

	COPY_NODE_FIELD(funcexpr);
	COPY_SCALAR_FIELD(funccolcount);
	COPY_NODE_FIELD(funccolnames);
	COPY_NODE_FIELD(funccoltypes);
	COPY_NODE_FIELD(funccoltypmods);
	COPY_NODE_FIELD(funccolcollations);
	COPY_BITMAPSET_FIELD(funcparams);

	return fc_newnode;
}

static TableSampleClause * fc__copyTableSampleClause(const TableSampleClause *fc_from)
{
	TableSampleClause *fc_newnode = makeNode(TableSampleClause);

	COPY_SCALAR_FIELD(tsmhandler);
	COPY_NODE_FIELD(args);
	COPY_NODE_FIELD(repeatable);

	return fc_newnode;
}

static WithCheckOption *
fc__copyWithCheckOption(const WithCheckOption *fc_from)
{
	WithCheckOption *fc_newnode = makeNode(WithCheckOption);

	COPY_SCALAR_FIELD(kind);
	COPY_STRING_FIELD(relname);
	COPY_STRING_FIELD(polname);
	COPY_NODE_FIELD(qual);
	COPY_SCALAR_FIELD(cascaded);

	return fc_newnode;
}

static SortGroupClause *
fc__copySortGroupClause(const SortGroupClause *fc_from)
{
	SortGroupClause *fc_newnode = makeNode(SortGroupClause);

	COPY_SCALAR_FIELD(tleSortGroupRef);
	COPY_SCALAR_FIELD(eqop);
	COPY_SCALAR_FIELD(sortop);
	COPY_SCALAR_FIELD(nulls_first);
	COPY_SCALAR_FIELD(hashable);

	return fc_newnode;
}

static GroupingSet *
fc__copyGroupingSet(const GroupingSet *fc_from)
{
	GroupingSet *fc_newnode = makeNode(GroupingSet);

	COPY_SCALAR_FIELD(kind);
	COPY_NODE_FIELD(content);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static WindowClause * fc__copyWindowClause(const WindowClause *fc_from)
{
	WindowClause *fc_newnode = makeNode(WindowClause);

	COPY_STRING_FIELD(name);
	COPY_STRING_FIELD(refname);
	COPY_NODE_FIELD(partitionClause);
	COPY_NODE_FIELD(orderClause);
	COPY_SCALAR_FIELD(frameOptions);
	COPY_NODE_FIELD(startOffset);
	COPY_NODE_FIELD(endOffset);
	COPY_NODE_FIELD(runCondition);
	COPY_SCALAR_FIELD(startInRangeFunc);
	COPY_SCALAR_FIELD(endInRangeFunc);
	COPY_SCALAR_FIELD(inRangeColl);
	COPY_SCALAR_FIELD(inRangeAsc);
	COPY_SCALAR_FIELD(inRangeNullsFirst);
	COPY_SCALAR_FIELD(winref);
	COPY_SCALAR_FIELD(copiedOrder);

	return fc_newnode;
}

static RowMarkClause *
fc__copyRowMarkClause(const RowMarkClause *fc_from)
{
	RowMarkClause *fc_newnode = makeNode(RowMarkClause);

	COPY_SCALAR_FIELD(rti);
	COPY_SCALAR_FIELD(strength);
	COPY_SCALAR_FIELD(waitPolicy);
	COPY_SCALAR_FIELD(pushedDown);

	return fc_newnode;
}

static WithClause *
fc__copyWithClause(const WithClause *fc_from)
{
	WithClause *fc_newnode = makeNode(WithClause);

	COPY_NODE_FIELD(ctes);
	COPY_SCALAR_FIELD(recursive);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static InferClause *
fc__copyInferClause(const InferClause *fc_from)
{
	InferClause *fc_newnode = makeNode(InferClause);

	COPY_NODE_FIELD(indexElems);
	COPY_NODE_FIELD(whereClause);
	COPY_STRING_FIELD(conname);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static OnConflictClause *
fc__copyOnConflictClause(const OnConflictClause *fc_from)
{
	OnConflictClause *fc_newnode = makeNode(OnConflictClause);

	COPY_SCALAR_FIELD(action);
	COPY_NODE_FIELD(infer);
	COPY_NODE_FIELD(targetList);
	COPY_NODE_FIELD(whereClause);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static CTESearchClause *
fc__copyCTESearchClause(const CTESearchClause *fc_from)
{
	CTESearchClause *fc_newnode = makeNode(CTESearchClause);

	COPY_NODE_FIELD(search_col_list);
	COPY_SCALAR_FIELD(search_breadth_first);
	COPY_STRING_FIELD(search_seq_column);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static CTECycleClause *
fc__copyCTECycleClause(const CTECycleClause *fc_from)
{
	CTECycleClause *fc_newnode = makeNode(CTECycleClause);

	COPY_NODE_FIELD(cycle_col_list);
	COPY_STRING_FIELD(cycle_mark_column);
	COPY_NODE_FIELD(cycle_mark_value);
	COPY_NODE_FIELD(cycle_mark_default);
	COPY_STRING_FIELD(cycle_path_column);
	COPY_LOCATION_FIELD(location);
	COPY_SCALAR_FIELD(cycle_mark_type);
	COPY_SCALAR_FIELD(cycle_mark_typmod);
	COPY_SCALAR_FIELD(cycle_mark_collation);
	COPY_SCALAR_FIELD(cycle_mark_neop);

	return fc_newnode;
}

static CommonTableExpr *
fc__copyCommonTableExpr(const CommonTableExpr *fc_from)
{
	CommonTableExpr *fc_newnode = makeNode(CommonTableExpr);

	COPY_STRING_FIELD(ctename);
	COPY_NODE_FIELD(aliascolnames);
	COPY_SCALAR_FIELD(ctematerialized);
	COPY_NODE_FIELD(ctequery);
	COPY_NODE_FIELD(search_clause);
	COPY_NODE_FIELD(cycle_clause);
	COPY_LOCATION_FIELD(location);
	COPY_SCALAR_FIELD(cterecursive);
	COPY_SCALAR_FIELD(cterefcount);
	COPY_NODE_FIELD(ctecolnames);
	COPY_NODE_FIELD(ctecoltypes);
	COPY_NODE_FIELD(ctecoltypmods);
	COPY_NODE_FIELD(ctecolcollations);

	return fc_newnode;
}

static MergeWhenClause *
fc__copyMergeWhenClause(const MergeWhenClause *fc_from)
{
	MergeWhenClause *fc_newnode = makeNode(MergeWhenClause);

	COPY_SCALAR_FIELD(matched);
	COPY_SCALAR_FIELD(commandType);
	COPY_SCALAR_FIELD(override);
	COPY_NODE_FIELD(condition);
	COPY_NODE_FIELD(targetList);
	COPY_NODE_FIELD(values);
	return fc_newnode;
}

static MergeAction *
fc__copyMergeAction(const MergeAction *fc_from)
{
	MergeAction *fc_newnode = makeNode(MergeAction);

	COPY_SCALAR_FIELD(matched);
	COPY_SCALAR_FIELD(commandType);
	COPY_SCALAR_FIELD(override);
	COPY_NODE_FIELD(qual);
	COPY_NODE_FIELD(targetList);
	COPY_NODE_FIELD(updateColnos);

	return fc_newnode;
}

static A_Expr *
fc__copyA_Expr(const A_Expr *fc_from)
{
	A_Expr	   *fc_newnode = makeNode(A_Expr);

	COPY_SCALAR_FIELD(kind);
	COPY_NODE_FIELD(name);
	COPY_NODE_FIELD(lexpr);
	COPY_NODE_FIELD(rexpr);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static ColumnRef *
fc__copyColumnRef(const ColumnRef *fc_from)
{
	ColumnRef  *fc_newnode = makeNode(ColumnRef);

	COPY_NODE_FIELD(fields);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static ParamRef *
fc__copyParamRef(const ParamRef *fc_from)
{
	ParamRef   *fc_newnode = makeNode(ParamRef);

	COPY_SCALAR_FIELD(number);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static A_Const *
fc__copyA_Const(const A_Const *fc_from)
{
	A_Const    *fc_newnode = makeNode(A_Const);

	COPY_SCALAR_FIELD(isnull);
	if (!fc_from->isnull)
	{
		/* 这一部分必须重复其他 _copy*() 函数。 */
		COPY_SCALAR_FIELD(val.node.type);
		switch (nodeTag(&fc_from->val))
		{
			case T_Integer:
				COPY_SCALAR_FIELD(val.ival.ival);
				break;
			case T_Float:
				COPY_STRING_FIELD(val.fval.fval);
				break;
			case T_Boolean:
				COPY_SCALAR_FIELD(val.boolval.boolval);
				break;
			case T_String:
				COPY_STRING_FIELD(val.sval.sval);
				break;
			case T_BitString:
				COPY_STRING_FIELD(val.bsval.bsval);
				break;
			default:
				elog(ERROR, "unrecognized node type: %d",
					 (int) nodeTag(&fc_from->val));
				break;
		}
	}

	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static FuncCall *
fc__copyFuncCall(const FuncCall *fc_from)
{
	FuncCall   *fc_newnode = makeNode(FuncCall);

	COPY_NODE_FIELD(funcname);
	COPY_NODE_FIELD(args);
	COPY_NODE_FIELD(agg_order);
	COPY_NODE_FIELD(agg_filter);
	COPY_NODE_FIELD(over);
	COPY_SCALAR_FIELD(agg_within_group);
	COPY_SCALAR_FIELD(agg_star);
	COPY_SCALAR_FIELD(agg_distinct);
	COPY_SCALAR_FIELD(func_variadic);
	COPY_SCALAR_FIELD(funcformat);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static A_Star *
fc__copyA_Star(const A_Star *fc_from)
{
	A_Star	   *fc_newnode = makeNode(A_Star);

	return fc_newnode;
}

static A_Indices *
fc__copyA_Indices(const A_Indices *fc_from)
{
	A_Indices  *fc_newnode = makeNode(A_Indices);

	COPY_SCALAR_FIELD(is_slice);
	COPY_NODE_FIELD(lidx);
	COPY_NODE_FIELD(uidx);

	return fc_newnode;
}

static A_Indirection *
fc__copyA_Indirection(const A_Indirection *fc_from)
{
	A_Indirection *fc_newnode = makeNode(A_Indirection);

	COPY_NODE_FIELD(arg);
	COPY_NODE_FIELD(indirection);

	return fc_newnode;
}

static A_ArrayExpr *
fc__copyA_ArrayExpr(const A_ArrayExpr *fc_from)
{
	A_ArrayExpr *fc_newnode = makeNode(A_ArrayExpr);

	COPY_NODE_FIELD(elements);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static ResTarget *
fc__copyResTarget(const ResTarget *fc_from)
{
	ResTarget  *fc_newnode = makeNode(ResTarget);

	COPY_STRING_FIELD(name);
	COPY_NODE_FIELD(indirection);
	COPY_NODE_FIELD(val);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static MultiAssignRef *
fc__copyMultiAssignRef(const MultiAssignRef *fc_from)
{
	MultiAssignRef *fc_newnode = makeNode(MultiAssignRef);

	COPY_NODE_FIELD(source);
	COPY_SCALAR_FIELD(colno);
	COPY_SCALAR_FIELD(ncolumns);

	return fc_newnode;
}

static TypeName *
fc__copyTypeName(const TypeName *fc_from)
{
	TypeName   *fc_newnode = makeNode(TypeName);

	COPY_NODE_FIELD(names);
	COPY_SCALAR_FIELD(typeOid);
	COPY_SCALAR_FIELD(setof);
	COPY_SCALAR_FIELD(pct_type);
	COPY_NODE_FIELD(typmods);
	COPY_SCALAR_FIELD(typemod);
	COPY_NODE_FIELD(arrayBounds);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static SortBy *
fc__copySortBy(const SortBy *fc_from)
{
	SortBy	   *fc_newnode = makeNode(SortBy);

	COPY_NODE_FIELD(node);
	COPY_SCALAR_FIELD(sortby_dir);
	COPY_SCALAR_FIELD(sortby_nulls);
	COPY_NODE_FIELD(useOp);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static WindowDef *
fc__copyWindowDef(const WindowDef *fc_from)
{
	WindowDef  *fc_newnode = makeNode(WindowDef);

	COPY_STRING_FIELD(name);
	COPY_STRING_FIELD(refname);
	COPY_NODE_FIELD(partitionClause);
	COPY_NODE_FIELD(orderClause);
	COPY_SCALAR_FIELD(frameOptions);
	COPY_NODE_FIELD(startOffset);
	COPY_NODE_FIELD(endOffset);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static RangeSubselect *
fc__copyRangeSubselect(const RangeSubselect *fc_from)
{
	RangeSubselect *fc_newnode = makeNode(RangeSubselect);

	COPY_SCALAR_FIELD(lateral);
	COPY_NODE_FIELD(subquery);
	COPY_NODE_FIELD(alias);

	return fc_newnode;
}

static RangeFunction *
fc__copyRangeFunction(const RangeFunction *fc_from)
{
	RangeFunction *fc_newnode = makeNode(RangeFunction);

	COPY_SCALAR_FIELD(lateral);
	COPY_SCALAR_FIELD(ordinality);
	COPY_SCALAR_FIELD(is_rowsfrom);
	COPY_NODE_FIELD(functions);
	COPY_NODE_FIELD(alias);
	COPY_NODE_FIELD(coldeflist);

	return fc_newnode;
}

static RangeTableSample *
fc__copyRangeTableSample(const RangeTableSample *fc_from)
{
	RangeTableSample *fc_newnode = makeNode(RangeTableSample);

	COPY_NODE_FIELD(relation);
	COPY_NODE_FIELD(method);
	COPY_NODE_FIELD(args);
	COPY_NODE_FIELD(repeatable);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static RangeTableFunc *
fc__copyRangeTableFunc(const RangeTableFunc *fc_from)
{
	RangeTableFunc *fc_newnode = makeNode(RangeTableFunc);

	COPY_SCALAR_FIELD(lateral);
	COPY_NODE_FIELD(docexpr);
	COPY_NODE_FIELD(rowexpr);
	COPY_NODE_FIELD(namespaces);
	COPY_NODE_FIELD(columns);
	COPY_NODE_FIELD(alias);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static RangeTableFuncCol *
fc__copyRangeTableFuncCol(const RangeTableFuncCol *fc_from)
{
	RangeTableFuncCol *fc_newnode = makeNode(RangeTableFuncCol);

	COPY_STRING_FIELD(colname);
	COPY_NODE_FIELD(typeName);
	COPY_SCALAR_FIELD(for_ordinality);
	COPY_SCALAR_FIELD(is_not_null);
	COPY_NODE_FIELD(colexpr);
	COPY_NODE_FIELD(coldefexpr);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static TypeCast *
fc__copyTypeCast(const TypeCast *fc_from)
{
	TypeCast   *fc_newnode = makeNode(TypeCast);

	COPY_NODE_FIELD(arg);
	COPY_NODE_FIELD(typeName);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static CollateClause *
fc__copyCollateClause(const CollateClause *fc_from)
{
	CollateClause *fc_newnode = makeNode(CollateClause);

	COPY_NODE_FIELD(arg);
	COPY_NODE_FIELD(collname);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static IndexElem *
fc__copyIndexElem(const IndexElem *fc_from)
{
	IndexElem  *fc_newnode = makeNode(IndexElem);

	COPY_STRING_FIELD(name);
	COPY_NODE_FIELD(expr);
	COPY_STRING_FIELD(indexcolname);
	COPY_NODE_FIELD(collation);
	COPY_NODE_FIELD(opclass);
	COPY_NODE_FIELD(opclassopts);
	COPY_SCALAR_FIELD(ordering);
	COPY_SCALAR_FIELD(nulls_ordering);

	return fc_newnode;
}

static StatsElem *
fc__copyStatsElem(const StatsElem *fc_from)
{
	StatsElem  *fc_newnode = makeNode(StatsElem);

	COPY_STRING_FIELD(name);
	COPY_NODE_FIELD(expr);

	return fc_newnode;
}

static ColumnDef *
fc__copyColumnDef(const ColumnDef *fc_from)
{
	ColumnDef  *fc_newnode = makeNode(ColumnDef);

	COPY_STRING_FIELD(colname);
	COPY_NODE_FIELD(typeName);
	COPY_STRING_FIELD(compression);
	COPY_SCALAR_FIELD(inhcount);
	COPY_SCALAR_FIELD(is_local);
	COPY_SCALAR_FIELD(is_not_null);
	COPY_SCALAR_FIELD(is_from_type);
	COPY_SCALAR_FIELD(storage);
	COPY_NODE_FIELD(raw_default);
	COPY_NODE_FIELD(cooked_default);
	COPY_SCALAR_FIELD(identity);
	COPY_NODE_FIELD(identitySequence);
	COPY_SCALAR_FIELD(generated);
	COPY_NODE_FIELD(collClause);
	COPY_SCALAR_FIELD(collOid);
	COPY_NODE_FIELD(constraints);
	COPY_NODE_FIELD(fdwoptions);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static Constraint *
fc__copyConstraint(const Constraint *fc_from)
{
	Constraint *fc_newnode = makeNode(Constraint);

	COPY_SCALAR_FIELD(contype);
	COPY_STRING_FIELD(conname);
	COPY_SCALAR_FIELD(deferrable);
	COPY_SCALAR_FIELD(initdeferred);
	COPY_LOCATION_FIELD(location);
	COPY_SCALAR_FIELD(is_no_inherit);
	COPY_NODE_FIELD(raw_expr);
	COPY_STRING_FIELD(cooked_expr);
	COPY_SCALAR_FIELD(generated_when);
	COPY_SCALAR_FIELD(nulls_not_distinct);
	COPY_NODE_FIELD(keys);
	COPY_NODE_FIELD(including);
	COPY_NODE_FIELD(exclusions);
	COPY_NODE_FIELD(options);
	COPY_STRING_FIELD(indexname);
	COPY_STRING_FIELD(indexspace);
	COPY_SCALAR_FIELD(reset_default_tblspc);
	COPY_STRING_FIELD(access_method);
	COPY_NODE_FIELD(where_clause);
	COPY_NODE_FIELD(pktable);
	COPY_NODE_FIELD(fk_attrs);
	COPY_NODE_FIELD(pk_attrs);
	COPY_SCALAR_FIELD(fk_matchtype);
	COPY_SCALAR_FIELD(fk_upd_action);
	COPY_SCALAR_FIELD(fk_del_action);
	COPY_NODE_FIELD(fk_del_set_cols);
	COPY_NODE_FIELD(old_conpfeqop);
	COPY_SCALAR_FIELD(old_pktable_oid);
	COPY_SCALAR_FIELD(skip_validation);
	COPY_SCALAR_FIELD(initially_valid);

	return fc_newnode;
}

static DefElem * fc__copyDefElem(const DefElem *fc_from)
{
	DefElem    *fc_newnode = makeNode(DefElem);

	COPY_STRING_FIELD(defnamespace);
	COPY_STRING_FIELD(defname);
	COPY_NODE_FIELD(arg);
	COPY_SCALAR_FIELD(defaction);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static LockingClause *
fc__copyLockingClause(const LockingClause *fc_from)
{
	LockingClause *fc_newnode = makeNode(LockingClause);

	COPY_NODE_FIELD(lockedRels);
	COPY_SCALAR_FIELD(strength);
	COPY_SCALAR_FIELD(waitPolicy);

	return fc_newnode;
}

static XmlSerialize *
fc__copyXmlSerialize(const XmlSerialize *fc_from)
{
	XmlSerialize *fc_newnode = makeNode(XmlSerialize);

	COPY_SCALAR_FIELD(xmloption);
	COPY_NODE_FIELD(expr);
	COPY_NODE_FIELD(typeName);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static RoleSpec *
fc__copyRoleSpec(const RoleSpec *fc_from)
{
	RoleSpec   *fc_newnode = makeNode(RoleSpec);

	COPY_SCALAR_FIELD(roletype);
	COPY_STRING_FIELD(rolename);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static TriggerTransition *
fc__copyTriggerTransition(const TriggerTransition *fc_from)
{
	TriggerTransition *fc_newnode = makeNode(TriggerTransition);

	COPY_STRING_FIELD(name);
	COPY_SCALAR_FIELD(isNew);
	COPY_SCALAR_FIELD(isTable);

	return fc_newnode;
}

static Query * fc__copyQuery(const Query *fc_from)
{
	Query	   *fc_newnode = makeNode(Query);

	COPY_SCALAR_FIELD(commandType);
	COPY_SCALAR_FIELD(querySource);
	COPY_SCALAR_FIELD(queryId);
	COPY_SCALAR_FIELD(canSetTag);
	COPY_NODE_FIELD(utilityStmt);
	COPY_SCALAR_FIELD(resultRelation);
	COPY_SCALAR_FIELD(hasAggs);
	COPY_SCALAR_FIELD(hasWindowFuncs);
	COPY_SCALAR_FIELD(hasTargetSRFs);
	COPY_SCALAR_FIELD(hasSubLinks);
	COPY_SCALAR_FIELD(hasDistinctOn);
	COPY_SCALAR_FIELD(hasRecursive);
	COPY_SCALAR_FIELD(hasModifyingCTE);
	COPY_SCALAR_FIELD(hasForUpdate);
	COPY_SCALAR_FIELD(hasRowSecurity);
	COPY_SCALAR_FIELD(isReturn);
	COPY_NODE_FIELD(cteList);
	COPY_NODE_FIELD(rtable);
	COPY_NODE_FIELD(jointree);
	COPY_NODE_FIELD(targetList);
	COPY_SCALAR_FIELD(override);
	COPY_NODE_FIELD(onConflict);
	COPY_NODE_FIELD(returningList);
	COPY_NODE_FIELD(groupClause);
	COPY_SCALAR_FIELD(groupDistinct);
	COPY_NODE_FIELD(groupingSets);
	COPY_NODE_FIELD(havingQual);
	COPY_NODE_FIELD(windowClause);
	COPY_NODE_FIELD(distinctClause);
	COPY_NODE_FIELD(sortClause);
	COPY_NODE_FIELD(limitOffset);
	COPY_NODE_FIELD(limitCount);
	COPY_SCALAR_FIELD(limitOption);
	COPY_NODE_FIELD(rowMarks);
	COPY_NODE_FIELD(setOperations);
	COPY_NODE_FIELD(constraintDeps);
	COPY_NODE_FIELD(withCheckOptions);
	COPY_NODE_FIELD(mergeActionList);
	COPY_SCALAR_FIELD(mergeUseOuterJoin);
	COPY_LOCATION_FIELD(stmt_location);
	COPY_SCALAR_FIELD(stmt_len);

	return fc_newnode;
}

static RawStmt *
fc__copyRawStmt(const RawStmt *fc_from)
{
	RawStmt    *fc_newnode = makeNode(RawStmt);

	COPY_NODE_FIELD(stmt);
	COPY_LOCATION_FIELD(stmt_location);
	COPY_SCALAR_FIELD(stmt_len);

	return fc_newnode;
}

static InsertStmt *
fc__copyInsertStmt(const InsertStmt *fc_from)
{
	InsertStmt *fc_newnode = makeNode(InsertStmt);

	COPY_NODE_FIELD(relation);
	COPY_NODE_FIELD(cols);
	COPY_NODE_FIELD(selectStmt);
	COPY_NODE_FIELD(onConflictClause);
	COPY_NODE_FIELD(returningList);
	COPY_NODE_FIELD(withClause);
	COPY_SCALAR_FIELD(override);

	return fc_newnode;
}

static DeleteStmt *
fc__copyDeleteStmt(const DeleteStmt *fc_from)
{
	DeleteStmt *fc_newnode = makeNode(DeleteStmt);

	COPY_NODE_FIELD(relation);
	COPY_NODE_FIELD(usingClause);
	COPY_NODE_FIELD(whereClause);
	COPY_NODE_FIELD(returningList);
	COPY_NODE_FIELD(withClause);

	return fc_newnode;
}

static UpdateStmt *
fc__copyUpdateStmt(const UpdateStmt *fc_from)
{
	UpdateStmt *fc_newnode = makeNode(UpdateStmt);

	COPY_NODE_FIELD(relation);
	COPY_NODE_FIELD(targetList);
	COPY_NODE_FIELD(whereClause);
	COPY_NODE_FIELD(fromClause);
	COPY_NODE_FIELD(returningList);
	COPY_NODE_FIELD(withClause);

	return fc_newnode;
}

static MergeStmt *
fc__copyMergeStmt(const MergeStmt *fc_from)
{
	MergeStmt  *fc_newnode = makeNode(MergeStmt);

	COPY_NODE_FIELD(relation);
	COPY_NODE_FIELD(sourceRelation);
	COPY_NODE_FIELD(joinCondition);
	COPY_NODE_FIELD(mergeWhenClauses);
	COPY_NODE_FIELD(withClause);

	return fc_newnode;
}

static SelectStmt *
fc__copySelectStmt(const SelectStmt *fc_from)
{
	SelectStmt *fc_newnode = makeNode(SelectStmt);

	COPY_NODE_FIELD(distinctClause);
	COPY_NODE_FIELD(intoClause);
	COPY_NODE_FIELD(targetList);
	COPY_NODE_FIELD(fromClause);
	COPY_NODE_FIELD(whereClause);
	COPY_NODE_FIELD(groupClause);
	COPY_SCALAR_FIELD(groupDistinct);
	COPY_NODE_FIELD(havingClause);
	COPY_NODE_FIELD(windowClause);
	COPY_NODE_FIELD(valuesLists);
	COPY_NODE_FIELD(sortClause);
	COPY_NODE_FIELD(limitOffset);
	COPY_NODE_FIELD(limitCount);
	COPY_SCALAR_FIELD(limitOption);
	COPY_NODE_FIELD(lockingClause);
	COPY_NODE_FIELD(withClause);
	COPY_SCALAR_FIELD(op);
	COPY_SCALAR_FIELD(all);
	COPY_NODE_FIELD(larg);
	COPY_NODE_FIELD(rarg);

	return fc_newnode;
}

static SetOperationStmt *
fc__copySetOperationStmt(const SetOperationStmt *fc_from)
{
	SetOperationStmt *fc_newnode = makeNode(SetOperationStmt);

	COPY_SCALAR_FIELD(op);
	COPY_SCALAR_FIELD(all);
	COPY_NODE_FIELD(larg);
	COPY_NODE_FIELD(rarg);
	COPY_NODE_FIELD(colTypes);
	COPY_NODE_FIELD(colTypmods);
	COPY_NODE_FIELD(colCollations);
	COPY_NODE_FIELD(groupClauses);

	return fc_newnode;
}

static ReturnStmt *
fc__copyReturnStmt(const ReturnStmt *fc_from)
{
	ReturnStmt *fc_newnode = makeNode(ReturnStmt);

	COPY_NODE_FIELD(returnval);

	return fc_newnode;
}

static PLAssignStmt *
fc__copyPLAssignStmt(const PLAssignStmt *fc_from)
{
	PLAssignStmt *fc_newnode = makeNode(PLAssignStmt);

	COPY_STRING_FIELD(name);
	COPY_NODE_FIELD(indirection);
	COPY_SCALAR_FIELD(nnames);
	COPY_NODE_FIELD(val);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static AlterTableStmt *
fc__copyAlterTableStmt(const AlterTableStmt *fc_from)
{
	AlterTableStmt *fc_newnode = makeNode(AlterTableStmt);

	COPY_NODE_FIELD(relation);
	COPY_NODE_FIELD(cmds);
	COPY_SCALAR_FIELD(objtype);
	COPY_SCALAR_FIELD(missing_ok);

	return fc_newnode;
}

static AlterTableCmd *
fc__copyAlterTableCmd(const AlterTableCmd *fc_from)
{
	AlterTableCmd *fc_newnode = makeNode(AlterTableCmd);

	COPY_SCALAR_FIELD(subtype);
	COPY_STRING_FIELD(name);
	COPY_SCALAR_FIELD(num);
	COPY_NODE_FIELD(newowner);
	COPY_NODE_FIELD(def);
	COPY_SCALAR_FIELD(behavior);
	COPY_SCALAR_FIELD(missing_ok);
	COPY_SCALAR_FIELD(recurse);

	return fc_newnode;
}

static AlterCollationStmt *
fc__copyAlterCollationStmt(const AlterCollationStmt *fc_from)
{
	AlterCollationStmt *fc_newnode = makeNode(AlterCollationStmt);

	COPY_NODE_FIELD(collname);

	return fc_newnode;
}

static AlterDomainStmt *
fc__copyAlterDomainStmt(const AlterDomainStmt *fc_from)
{
	AlterDomainStmt *fc_newnode = makeNode(AlterDomainStmt);

	COPY_SCALAR_FIELD(subtype);
	COPY_NODE_FIELD(typeName);
	COPY_STRING_FIELD(name);
	COPY_NODE_FIELD(def);
	COPY_SCALAR_FIELD(behavior);
	COPY_SCALAR_FIELD(missing_ok);

	return fc_newnode;
}

static GrantStmt *
fc__copyGrantStmt(const GrantStmt *fc_from)
{
	GrantStmt  *fc_newnode = makeNode(GrantStmt);

	COPY_SCALAR_FIELD(is_grant);
	COPY_SCALAR_FIELD(targtype);
	COPY_SCALAR_FIELD(objtype);
	COPY_NODE_FIELD(objects);
	COPY_NODE_FIELD(privileges);
	COPY_NODE_FIELD(grantees);
	COPY_SCALAR_FIELD(grant_option);
	COPY_NODE_FIELD(grantor);
	COPY_SCALAR_FIELD(behavior);

	return fc_newnode;
}

static ObjectWithArgs *
fc__copyObjectWithArgs(const ObjectWithArgs *fc_from)
{
	ObjectWithArgs *fc_newnode = makeNode(ObjectWithArgs);

	COPY_NODE_FIELD(objname);
	COPY_NODE_FIELD(objargs);
	COPY_NODE_FIELD(objfuncargs);
	COPY_SCALAR_FIELD(args_unspecified);

	return fc_newnode;
}

static AccessPriv *
fc__copyAccessPriv(const AccessPriv *fc_from)
{
	AccessPriv *fc_newnode = makeNode(AccessPriv);

	COPY_STRING_FIELD(priv_name);
	COPY_NODE_FIELD(cols);

	return fc_newnode;
}

static GrantRoleStmt *
fc__copyGrantRoleStmt(const GrantRoleStmt *fc_from)
{
	GrantRoleStmt *fc_newnode = makeNode(GrantRoleStmt);

	COPY_NODE_FIELD(granted_roles);
	COPY_NODE_FIELD(grantee_roles);
	COPY_SCALAR_FIELD(is_grant);
	COPY_SCALAR_FIELD(admin_opt);
	COPY_NODE_FIELD(grantor);
	COPY_SCALAR_FIELD(behavior);

	return fc_newnode;
}

static AlterDefaultPrivilegesStmt *
fc__copyAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *fc_from)
{
	AlterDefaultPrivilegesStmt *fc_newnode = makeNode(AlterDefaultPrivilegesStmt);

	COPY_NODE_FIELD(options);
	COPY_NODE_FIELD(action);

	return fc_newnode;
}

static DeclareCursorStmt *
fc__copyDeclareCursorStmt(const DeclareCursorStmt *fc_from)
{
	DeclareCursorStmt *fc_newnode = makeNode(DeclareCursorStmt);

	COPY_STRING_FIELD(portalname);
	COPY_SCALAR_FIELD(options);
	COPY_NODE_FIELD(query);

	return fc_newnode;
}

static ClosePortalStmt *
fc__copyClosePortalStmt(const ClosePortalStmt *fc_from)
{
	ClosePortalStmt *fc_newnode = makeNode(ClosePortalStmt);

	COPY_STRING_FIELD(portalname);

	return fc_newnode;
}

static CallStmt *
fc__copyCallStmt(const CallStmt *fc_from)
{
	CallStmt   *fc_newnode = makeNode(CallStmt);

	COPY_NODE_FIELD(funccall);
	COPY_NODE_FIELD(funcexpr);
	COPY_NODE_FIELD(outargs);

	return fc_newnode;
}

static ClusterStmt *
fc__copyClusterStmt(const ClusterStmt *fc_from)
{
	ClusterStmt *fc_newnode = makeNode(ClusterStmt);

	COPY_NODE_FIELD(relation);
	COPY_STRING_FIELD(indexname);
	COPY_NODE_FIELD(params);

	return fc_newnode;
}

static CopyStmt *
fc__copyCopyStmt(const CopyStmt *fc_from)
{
	CopyStmt   *fc_newnode = makeNode(CopyStmt);

	COPY_NODE_FIELD(relation);
	COPY_NODE_FIELD(query);
	COPY_NODE_FIELD(attlist);
	COPY_SCALAR_FIELD(is_from);
	COPY_SCALAR_FIELD(is_program);
	COPY_STRING_FIELD(filename);
	COPY_NODE_FIELD(options);
	COPY_NODE_FIELD(whereClause);

	return fc_newnode;
}

/*
 * CopyCreateStmtFields
 *
 *		此函数复制 CreateStmt 节点的字段。它由
 *		继承自 CreateStmt 的类的复制函数使用。
 */
static void fc_CopyCreateStmtFields(const CreateStmt *fc_from, CreateStmt *fc_newnode)
{
	COPY_NODE_FIELD(relation);
	COPY_NODE_FIELD(tableElts);
	COPY_NODE_FIELD(inhRelations);
	COPY_NODE_FIELD(partspec);
	COPY_NODE_FIELD(partbound);
	COPY_NODE_FIELD(ofTypename);
	COPY_NODE_FIELD(constraints);
	COPY_NODE_FIELD(options);
	COPY_SCALAR_FIELD(oncommit);
	COPY_STRING_FIELD(tablespacename);
	COPY_STRING_FIELD(accessMethod);
	COPY_SCALAR_FIELD(if_not_exists);
}

static CreateStmt *
fc__copyCreateStmt(const CreateStmt *fc_from)
{
	CreateStmt *fc_newnode = makeNode(CreateStmt);

	fc_CopyCreateStmtFields(fc_from, fc_newnode);

	return fc_newnode;
}

static TableLikeClause *
fc__copyTableLikeClause(const TableLikeClause *fc_from)
{
	TableLikeClause *fc_newnode = makeNode(TableLikeClause);

	COPY_NODE_FIELD(relation);
	COPY_SCALAR_FIELD(options);
	COPY_SCALAR_FIELD(relationOid);

	return fc_newnode;
}

static DefineStmt *
fc__copyDefineStmt(const DefineStmt *fc_from)
{
	DefineStmt *fc_newnode = makeNode(DefineStmt);

	COPY_SCALAR_FIELD(kind);
	COPY_SCALAR_FIELD(oldstyle);
	COPY_NODE_FIELD(defnames);
	COPY_NODE_FIELD(args);
	COPY_NODE_FIELD(definition);
	COPY_SCALAR_FIELD(if_not_exists);
	COPY_SCALAR_FIELD(replace);

	return fc_newnode;
}

static DropStmt *
fc__copyDropStmt(const DropStmt *fc_from)
{
	DropStmt   *fc_newnode = makeNode(DropStmt);

	COPY_NODE_FIELD(objects);
	COPY_SCALAR_FIELD(removeType);
	COPY_SCALAR_FIELD(behavior);
	COPY_SCALAR_FIELD(missing_ok);
	COPY_SCALAR_FIELD(concurrent);

	return fc_newnode;
}

static TruncateStmt *
fc__copyTruncateStmt(const TruncateStmt *fc_from)
{
	TruncateStmt *fc_newnode = makeNode(TruncateStmt);

	COPY_NODE_FIELD(relations);
	COPY_SCALAR_FIELD(restart_seqs);
	COPY_SCALAR_FIELD(behavior);

	return fc_newnode;
}

static CommentStmt *
fc__copyCommentStmt(const CommentStmt *fc_from)
{
	CommentStmt *fc_newnode = makeNode(CommentStmt);

	COPY_SCALAR_FIELD(objtype);
	COPY_NODE_FIELD(object);
	COPY_STRING_FIELD(comment);

	return fc_newnode;
}

static SecLabelStmt *
fc__copySecLabelStmt(const SecLabelStmt *fc_from)
{
	SecLabelStmt *fc_newnode = makeNode(SecLabelStmt);

	COPY_SCALAR_FIELD(objtype);
	COPY_NODE_FIELD(object);
	COPY_STRING_FIELD(provider);
	COPY_STRING_FIELD(label);

	return fc_newnode;
}

static FetchStmt *
fc__copyFetchStmt(const FetchStmt *fc_from)
{
	FetchStmt  *fc_newnode = makeNode(FetchStmt);

	COPY_SCALAR_FIELD(direction);
	COPY_SCALAR_FIELD(howMany);
	COPY_STRING_FIELD(portalname);
	COPY_SCALAR_FIELD(ismove);

	return fc_newnode;
}

static IndexStmt *
fc__copyIndexStmt(const IndexStmt *fc_from)
{
	IndexStmt  *fc_newnode = makeNode(IndexStmt);

	COPY_STRING_FIELD(idxname);
	COPY_NODE_FIELD(relation);
	COPY_STRING_FIELD(accessMethod);
	COPY_STRING_FIELD(tableSpace);
	COPY_NODE_FIELD(indexParams);
	COPY_NODE_FIELD(indexIncludingParams);
	COPY_NODE_FIELD(options);
	COPY_NODE_FIELD(whereClause);
	COPY_NODE_FIELD(excludeOpNames);
	COPY_STRING_FIELD(idxcomment);
	COPY_SCALAR_FIELD(indexOid);
	COPY_SCALAR_FIELD(oldNode);
	COPY_SCALAR_FIELD(oldCreateSubid);
	COPY_SCALAR_FIELD(oldFirstRelfilenodeSubid);
	COPY_SCALAR_FIELD(unique);
	COPY_SCALAR_FIELD(nulls_not_distinct);
	COPY_SCALAR_FIELD(primary);
	COPY_SCALAR_FIELD(isconstraint);
	COPY_SCALAR_FIELD(deferrable);
	COPY_SCALAR_FIELD(initdeferred);
	COPY_SCALAR_FIELD(transformed);
	COPY_SCALAR_FIELD(concurrent);
	COPY_SCALAR_FIELD(if_not_exists);
	COPY_SCALAR_FIELD(reset_default_tblspc);

	return fc_newnode;
}

static CreateStatsStmt *
fc__copyCreateStatsStmt(const CreateStatsStmt *fc_from)
{
	CreateStatsStmt *fc_newnode = makeNode(CreateStatsStmt);

	COPY_NODE_FIELD(defnames);
	COPY_NODE_FIELD(stat_types);
	COPY_NODE_FIELD(exprs);
	COPY_NODE_FIELD(relations);
	COPY_STRING_FIELD(stxcomment);
	COPY_SCALAR_FIELD(transformed);
	COPY_SCALAR_FIELD(if_not_exists);

	return fc_newnode;
}

static AlterStatsStmt *
fc__copyAlterStatsStmt(const AlterStatsStmt *fc_from)
{
	AlterStatsStmt *fc_newnode = makeNode(AlterStatsStmt);

	COPY_NODE_FIELD(defnames);
	COPY_SCALAR_FIELD(stxstattarget);
	COPY_SCALAR_FIELD(missing_ok);

	return fc_newnode;
}

static CreateFunctionStmt *
fc__copyCreateFunctionStmt(const CreateFunctionStmt *fc_from)
{
	CreateFunctionStmt *fc_newnode = makeNode(CreateFunctionStmt);

	COPY_SCALAR_FIELD(is_procedure);
	COPY_SCALAR_FIELD(replace);
	COPY_NODE_FIELD(funcname);
	COPY_NODE_FIELD(parameters);
	COPY_NODE_FIELD(returnType);
	COPY_NODE_FIELD(options);
	COPY_NODE_FIELD(sql_body);

	return fc_newnode;
}

static FunctionParameter *
fc__copyFunctionParameter(const FunctionParameter *fc_from)
{
	FunctionParameter *fc_newnode = makeNode(FunctionParameter);

	COPY_STRING_FIELD(name);
	COPY_NODE_FIELD(argType);
	COPY_SCALAR_FIELD(mode);
	COPY_NODE_FIELD(defexpr);

	return fc_newnode;
}

static AlterFunctionStmt *
fc__copyAlterFunctionStmt(const AlterFunctionStmt *fc_from)
{
	AlterFunctionStmt *fc_newnode = makeNode(AlterFunctionStmt);

	COPY_SCALAR_FIELD(objtype);
	COPY_NODE_FIELD(func);
	COPY_NODE_FIELD(actions);

	return fc_newnode;
}

static DoStmt *
fc__copyDoStmt(const DoStmt *fc_from)
{
	DoStmt	   *fc_newnode = makeNode(DoStmt);

	COPY_NODE_FIELD(args);

	return fc_newnode;
}

static RenameStmt *
fc__copyRenameStmt(const RenameStmt *fc_from)
{
	RenameStmt *fc_newnode = makeNode(RenameStmt);

	COPY_SCALAR_FIELD(renameType);
	COPY_SCALAR_FIELD(relationType);
	COPY_NODE_FIELD(relation);
	COPY_NODE_FIELD(object);
	COPY_STRING_FIELD(subname);
	COPY_STRING_FIELD(newname);
	COPY_SCALAR_FIELD(behavior);
	COPY_SCALAR_FIELD(missing_ok);

	return fc_newnode;
}

static AlterObjectDependsStmt *
fc__copyAlterObjectDependsStmt(const AlterObjectDependsStmt *fc_from)
{
	AlterObjectDependsStmt *fc_newnode = makeNode(AlterObjectDependsStmt);

	COPY_SCALAR_FIELD(objectType);
	COPY_NODE_FIELD(relation);
	COPY_NODE_FIELD(object);
	COPY_NODE_FIELD(extname);
	COPY_SCALAR_FIELD(remove);

	return fc_newnode;
}

static AlterObjectSchemaStmt *
fc__copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *fc_from)
{
	AlterObjectSchemaStmt *fc_newnode = makeNode(AlterObjectSchemaStmt);

	COPY_SCALAR_FIELD(objectType);
	COPY_NODE_FIELD(relation);
	COPY_NODE_FIELD(object);
	COPY_STRING_FIELD(newschema);
	COPY_SCALAR_FIELD(missing_ok);

	return fc_newnode;
}

static AlterOwnerStmt *
fc__copyAlterOwnerStmt(const AlterOwnerStmt *fc_from)
{
	AlterOwnerStmt *fc_newnode = makeNode(AlterOwnerStmt);

	COPY_SCALAR_FIELD(objectType);
	COPY_NODE_FIELD(relation);
	COPY_NODE_FIELD(object);
	COPY_NODE_FIELD(newowner);

	return fc_newnode;
}

static AlterOperatorStmt *
fc__copyAlterOperatorStmt(const AlterOperatorStmt *fc_from)
{
	AlterOperatorStmt *fc_newnode = makeNode(AlterOperatorStmt);

	COPY_NODE_FIELD(opername);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static AlterTypeStmt *
fc__copyAlterTypeStmt(const AlterTypeStmt *fc_from)
{
	AlterTypeStmt *fc_newnode = makeNode(AlterTypeStmt);

	COPY_NODE_FIELD(typeName);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static RuleStmt *
fc__copyRuleStmt(const RuleStmt *fc_from)
{
	RuleStmt   *fc_newnode = makeNode(RuleStmt);

	COPY_NODE_FIELD(relation);
	COPY_STRING_FIELD(rulename);
	COPY_NODE_FIELD(whereClause);
	COPY_SCALAR_FIELD(event);
	COPY_SCALAR_FIELD(instead);
	COPY_NODE_FIELD(actions);
	COPY_SCALAR_FIELD(replace);

	return fc_newnode;
}

static NotifyStmt *
fc__copyNotifyStmt(const NotifyStmt *fc_from)
{
	NotifyStmt *fc_newnode = makeNode(NotifyStmt);

	COPY_STRING_FIELD(conditionname);
	COPY_STRING_FIELD(payload);

	return fc_newnode;
}

static ListenStmt *
fc__copyListenStmt(const ListenStmt *fc_from)
{
	ListenStmt *fc_newnode = makeNode(ListenStmt);

	COPY_STRING_FIELD(conditionname);

	return fc_newnode;
}

static UnlistenStmt *
fc__copyUnlistenStmt(const UnlistenStmt *fc_from)
{
	UnlistenStmt *fc_newnode = makeNode(UnlistenStmt);

	COPY_STRING_FIELD(conditionname);

	return fc_newnode;
}

static TransactionStmt *
fc__copyTransactionStmt(const TransactionStmt *fc_from)
{
	TransactionStmt *fc_newnode = makeNode(TransactionStmt);

	COPY_SCALAR_FIELD(kind);
	COPY_NODE_FIELD(options);
	COPY_STRING_FIELD(savepoint_name);
	COPY_STRING_FIELD(gid);
	COPY_SCALAR_FIELD(chain);

	return fc_newnode;
}

static CompositeTypeStmt *
fc__copyCompositeTypeStmt(const CompositeTypeStmt *fc_from)
{
	CompositeTypeStmt *fc_newnode = makeNode(CompositeTypeStmt);

	COPY_NODE_FIELD(typevar);
	COPY_NODE_FIELD(coldeflist);

	return fc_newnode;
}

static CreateEnumStmt *
fc__copyCreateEnumStmt(const CreateEnumStmt *fc_from)
{
	CreateEnumStmt *fc_newnode = makeNode(CreateEnumStmt);

	COPY_NODE_FIELD(typeName);
	COPY_NODE_FIELD(vals);

	return fc_newnode;
}

static CreateRangeStmt *
fc__copyCreateRangeStmt(const CreateRangeStmt *fc_from)
{
	CreateRangeStmt *fc_newnode = makeNode(CreateRangeStmt);

	COPY_NODE_FIELD(typeName);
	COPY_NODE_FIELD(params);

	return fc_newnode;
}

static AlterEnumStmt *
fc__copyAlterEnumStmt(const AlterEnumStmt *fc_from)
{
	AlterEnumStmt *fc_newnode = makeNode(AlterEnumStmt);

	COPY_NODE_FIELD(typeName);
	COPY_STRING_FIELD(oldVal);
	COPY_STRING_FIELD(newVal);
	COPY_STRING_FIELD(newValNeighbor);
	COPY_SCALAR_FIELD(newValIsAfter);
	COPY_SCALAR_FIELD(skipIfNewValExists);

	return fc_newnode;
}

static ViewStmt *
fc__copyViewStmt(const ViewStmt *fc_from)
{
	ViewStmt   *fc_newnode = makeNode(ViewStmt);

	COPY_NODE_FIELD(view);
	COPY_NODE_FIELD(aliases);
	COPY_NODE_FIELD(query);
	COPY_SCALAR_FIELD(replace);
	COPY_NODE_FIELD(options);
	COPY_SCALAR_FIELD(withCheckOption);

	return fc_newnode;
}

static LoadStmt *
fc__copyLoadStmt(const LoadStmt *fc_from)
{
	LoadStmt   *fc_newnode = makeNode(LoadStmt);

	COPY_STRING_FIELD(filename);

	return fc_newnode;
}

static CreateDomainStmt *
fc__copyCreateDomainStmt(const CreateDomainStmt *fc_from)
{
	CreateDomainStmt *fc_newnode = makeNode(CreateDomainStmt);

	COPY_NODE_FIELD(domainname);
	COPY_NODE_FIELD(typeName);
	COPY_NODE_FIELD(collClause);
	COPY_NODE_FIELD(constraints);

	return fc_newnode;
}

static CreateOpClassStmt *
fc__copyCreateOpClassStmt(const CreateOpClassStmt *fc_from)
{
	CreateOpClassStmt *fc_newnode = makeNode(CreateOpClassStmt);

	COPY_NODE_FIELD(opclassname);
	COPY_NODE_FIELD(opfamilyname);
	COPY_STRING_FIELD(amname);
	COPY_NODE_FIELD(datatype);
	COPY_NODE_FIELD(items);
	COPY_SCALAR_FIELD(isDefault);

	return fc_newnode;
}

static CreateOpClassItem *
fc__copyCreateOpClassItem(const CreateOpClassItem *fc_from)
{
	CreateOpClassItem *fc_newnode = makeNode(CreateOpClassItem);

	COPY_SCALAR_FIELD(itemtype);
	COPY_NODE_FIELD(name);
	COPY_SCALAR_FIELD(number);
	COPY_NODE_FIELD(order_family);
	COPY_NODE_FIELD(class_args);
	COPY_NODE_FIELD(storedtype);

	return fc_newnode;
}

static CreateOpFamilyStmt *
fc__copyCreateOpFamilyStmt(const CreateOpFamilyStmt *fc_from)
{
	CreateOpFamilyStmt *fc_newnode = makeNode(CreateOpFamilyStmt);

	COPY_NODE_FIELD(opfamilyname);
	COPY_STRING_FIELD(amname);

	return fc_newnode;
}

static AlterOpFamilyStmt *
fc__copyAlterOpFamilyStmt(const AlterOpFamilyStmt *fc_from)
{
	AlterOpFamilyStmt *fc_newnode = makeNode(AlterOpFamilyStmt);

	COPY_NODE_FIELD(opfamilyname);
	COPY_STRING_FIELD(amname);
	COPY_SCALAR_FIELD(isDrop);
	COPY_NODE_FIELD(items);

	return fc_newnode;
}

static CreatedbStmt *
fc__copyCreatedbStmt(const CreatedbStmt *fc_from)
{
	CreatedbStmt *fc_newnode = makeNode(CreatedbStmt);

	COPY_STRING_FIELD(dbname);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static AlterDatabaseStmt *
fc__copyAlterDatabaseStmt(const AlterDatabaseStmt *fc_from)
{
	AlterDatabaseStmt *fc_newnode = makeNode(AlterDatabaseStmt);

	COPY_STRING_FIELD(dbname);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static AlterDatabaseRefreshCollStmt *
fc__copyAlterDatabaseRefreshCollStmt(const AlterDatabaseRefreshCollStmt *fc_from)
{
	AlterDatabaseRefreshCollStmt *fc_newnode = makeNode(AlterDatabaseRefreshCollStmt);

	COPY_STRING_FIELD(dbname);

	return fc_newnode;
}

static AlterDatabaseSetStmt *
fc__copyAlterDatabaseSetStmt(const AlterDatabaseSetStmt *fc_from)
{
	AlterDatabaseSetStmt *fc_newnode = makeNode(AlterDatabaseSetStmt);

	COPY_STRING_FIELD(dbname);
	COPY_NODE_FIELD(setstmt);

	return fc_newnode;
}

static DropdbStmt *
fc__copyDropdbStmt(const DropdbStmt *fc_from)
{
	DropdbStmt *fc_newnode = makeNode(DropdbStmt);

	COPY_STRING_FIELD(dbname);
	COPY_SCALAR_FIELD(missing_ok);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static VacuumStmt *
fc__copyVacuumStmt(const VacuumStmt *fc_from)
{
	VacuumStmt *fc_newnode = makeNode(VacuumStmt);

	COPY_NODE_FIELD(options);
	COPY_NODE_FIELD(rels);
	COPY_SCALAR_FIELD(is_vacuumcmd);

	return fc_newnode;
}

static VacuumRelation *
fc__copyVacuumRelation(const VacuumRelation *fc_from)
{
	VacuumRelation *fc_newnode = makeNode(VacuumRelation);

	COPY_NODE_FIELD(relation);
	COPY_SCALAR_FIELD(oid);
	COPY_NODE_FIELD(va_cols);

	return fc_newnode;
}

static ExplainStmt *
fc__copyExplainStmt(const ExplainStmt *fc_from)
{
	ExplainStmt *fc_newnode = makeNode(ExplainStmt);

	COPY_NODE_FIELD(query);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static CreateTableAsStmt *
fc__copyCreateTableAsStmt(const CreateTableAsStmt *fc_from)
{
	CreateTableAsStmt *fc_newnode = makeNode(CreateTableAsStmt);

	COPY_NODE_FIELD(query);
	COPY_NODE_FIELD(into);
	COPY_SCALAR_FIELD(objtype);
	COPY_SCALAR_FIELD(is_select_into);
	COPY_SCALAR_FIELD(if_not_exists);

	return fc_newnode;
}

static RefreshMatViewStmt *
fc__copyRefreshMatViewStmt(const RefreshMatViewStmt *fc_from)
{
	RefreshMatViewStmt *fc_newnode = makeNode(RefreshMatViewStmt);

	COPY_SCALAR_FIELD(concurrent);
	COPY_SCALAR_FIELD(skipData);
	COPY_NODE_FIELD(relation);

	return fc_newnode;
}

static ReplicaIdentityStmt *
fc__copyReplicaIdentityStmt(const ReplicaIdentityStmt *fc_from)
{
	ReplicaIdentityStmt *fc_newnode = makeNode(ReplicaIdentityStmt);

	COPY_SCALAR_FIELD(identity_type);
	COPY_STRING_FIELD(name);

	return fc_newnode;
}

static AlterSystemStmt *
fc__copyAlterSystemStmt(const AlterSystemStmt *fc_from)
{
	AlterSystemStmt *fc_newnode = makeNode(AlterSystemStmt);

	COPY_NODE_FIELD(setstmt);

	return fc_newnode;
}

static CreateSeqStmt *
fc__copyCreateSeqStmt(const CreateSeqStmt *fc_from)
{
	CreateSeqStmt *fc_newnode = makeNode(CreateSeqStmt);

	COPY_NODE_FIELD(sequence);
	COPY_NODE_FIELD(options);
	COPY_SCALAR_FIELD(ownerId);
	COPY_SCALAR_FIELD(for_identity);
	COPY_SCALAR_FIELD(if_not_exists);

	return fc_newnode;
}

static AlterSeqStmt *
fc__copyAlterSeqStmt(const AlterSeqStmt *fc_from)
{
	AlterSeqStmt *fc_newnode = makeNode(AlterSeqStmt);

	COPY_NODE_FIELD(sequence);
	COPY_NODE_FIELD(options);
	COPY_SCALAR_FIELD(for_identity);
	COPY_SCALAR_FIELD(missing_ok);

	return fc_newnode;
}

static VariableSetStmt *
fc__copyVariableSetStmt(const VariableSetStmt *fc_from)
{
	VariableSetStmt *fc_newnode = makeNode(VariableSetStmt);

	COPY_SCALAR_FIELD(kind);
	COPY_STRING_FIELD(name);
	COPY_NODE_FIELD(args);
	COPY_SCALAR_FIELD(is_local);

	return fc_newnode;
}

static VariableShowStmt *
fc__copyVariableShowStmt(const VariableShowStmt *fc_from)
{
	VariableShowStmt *fc_newnode = makeNode(VariableShowStmt);

	COPY_STRING_FIELD(name);

	return fc_newnode;
}

static DiscardStmt *
fc__copyDiscardStmt(const DiscardStmt *fc_from)
{
	DiscardStmt *fc_newnode = makeNode(DiscardStmt);

	COPY_SCALAR_FIELD(target);

	return fc_newnode;
}

static CreateTableSpaceStmt *
fc__copyCreateTableSpaceStmt(const CreateTableSpaceStmt *fc_from)
{
	CreateTableSpaceStmt *fc_newnode = makeNode(CreateTableSpaceStmt);

	COPY_STRING_FIELD(tablespacename);
	COPY_NODE_FIELD(owner);
	COPY_STRING_FIELD(location);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static DropTableSpaceStmt *
fc__copyDropTableSpaceStmt(const DropTableSpaceStmt *fc_from)
{
	DropTableSpaceStmt *fc_newnode = makeNode(DropTableSpaceStmt);

	COPY_STRING_FIELD(tablespacename);
	COPY_SCALAR_FIELD(missing_ok);

	return fc_newnode;
}

static AlterTableSpaceOptionsStmt *
fc__copyAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *fc_from)
{
	AlterTableSpaceOptionsStmt *fc_newnode = makeNode(AlterTableSpaceOptionsStmt);

	COPY_STRING_FIELD(tablespacename);
	COPY_NODE_FIELD(options);
	COPY_SCALAR_FIELD(isReset);

	return fc_newnode;
}

static AlterTableMoveAllStmt *
fc__copyAlterTableMoveAllStmt(const AlterTableMoveAllStmt *fc_from)
{
	AlterTableMoveAllStmt *fc_newnode = makeNode(AlterTableMoveAllStmt);

	COPY_STRING_FIELD(orig_tablespacename);
	COPY_SCALAR_FIELD(objtype);
	COPY_NODE_FIELD(roles);
	COPY_STRING_FIELD(new_tablespacename);
	COPY_SCALAR_FIELD(nowait);

	return fc_newnode;
}

static CreateExtensionStmt *
fc__copyCreateExtensionStmt(const CreateExtensionStmt *fc_from)
{
	CreateExtensionStmt *fc_newnode = makeNode(CreateExtensionStmt);

	COPY_STRING_FIELD(extname);
	COPY_SCALAR_FIELD(if_not_exists);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static AlterExtensionStmt *
fc__copyAlterExtensionStmt(const AlterExtensionStmt *fc_from)
{
	AlterExtensionStmt *fc_newnode = makeNode(AlterExtensionStmt);

	COPY_STRING_FIELD(extname);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static AlterExtensionContentsStmt *
fc__copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *fc_from)
{
	AlterExtensionContentsStmt *fc_newnode = makeNode(AlterExtensionContentsStmt);

	COPY_STRING_FIELD(extname);
	COPY_SCALAR_FIELD(action);
	COPY_SCALAR_FIELD(objtype);
	COPY_NODE_FIELD(object);

	return fc_newnode;
}

static CreateFdwStmt *
fc__copyCreateFdwStmt(const CreateFdwStmt *fc_from)
{
	CreateFdwStmt *fc_newnode = makeNode(CreateFdwStmt);

	COPY_STRING_FIELD(fdwname);
	COPY_NODE_FIELD(func_options);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static AlterFdwStmt *
fc__copyAlterFdwStmt(const AlterFdwStmt *fc_from)
{
	AlterFdwStmt *fc_newnode = makeNode(AlterFdwStmt);

	COPY_STRING_FIELD(fdwname);
	COPY_NODE_FIELD(func_options);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static CreateForeignServerStmt *
fc__copyCreateForeignServerStmt(const CreateForeignServerStmt *fc_from)
{
	CreateForeignServerStmt *fc_newnode = makeNode(CreateForeignServerStmt);

	COPY_STRING_FIELD(servername);
	COPY_STRING_FIELD(servertype);
	COPY_STRING_FIELD(version);
	COPY_STRING_FIELD(fdwname);
	COPY_SCALAR_FIELD(if_not_exists);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static AlterForeignServerStmt *
fc__copyAlterForeignServerStmt(const AlterForeignServerStmt *fc_from)
{
	AlterForeignServerStmt *fc_newnode = makeNode(AlterForeignServerStmt);

	COPY_STRING_FIELD(servername);
	COPY_STRING_FIELD(version);
	COPY_NODE_FIELD(options);
	COPY_SCALAR_FIELD(has_version);

	return fc_newnode;
}

static CreateUserMappingStmt *
fc__copyCreateUserMappingStmt(const CreateUserMappingStmt *fc_from)
{
	CreateUserMappingStmt *fc_newnode = makeNode(CreateUserMappingStmt);

	COPY_NODE_FIELD(user);
	COPY_STRING_FIELD(servername);
	COPY_SCALAR_FIELD(if_not_exists);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static AlterUserMappingStmt *
fc__copyAlterUserMappingStmt(const AlterUserMappingStmt *fc_from)
{
	AlterUserMappingStmt *fc_newnode = makeNode(AlterUserMappingStmt);

	COPY_NODE_FIELD(user);
	COPY_STRING_FIELD(servername);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static DropUserMappingStmt *
fc__copyDropUserMappingStmt(const DropUserMappingStmt *fc_from)
{
	DropUserMappingStmt *fc_newnode = makeNode(DropUserMappingStmt);

	COPY_NODE_FIELD(user);
	COPY_STRING_FIELD(servername);
	COPY_SCALAR_FIELD(missing_ok);

	return fc_newnode;
}

static CreateForeignTableStmt *
fc__copyCreateForeignTableStmt(const CreateForeignTableStmt *fc_from)
{
	CreateForeignTableStmt *fc_newnode = makeNode(CreateForeignTableStmt);

	fc_CopyCreateStmtFields((const CreateStmt *) fc_from, (CreateStmt *) fc_newnode);

	COPY_STRING_FIELD(servername);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static ImportForeignSchemaStmt *
fc__copyImportForeignSchemaStmt(const ImportForeignSchemaStmt *fc_from)
{
	ImportForeignSchemaStmt *fc_newnode = makeNode(ImportForeignSchemaStmt);

	COPY_STRING_FIELD(server_name);
	COPY_STRING_FIELD(remote_schema);
	COPY_STRING_FIELD(local_schema);
	COPY_SCALAR_FIELD(list_type);
	COPY_NODE_FIELD(table_list);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static CreateTransformStmt *
fc__copyCreateTransformStmt(const CreateTransformStmt *fc_from)
{
	CreateTransformStmt *fc_newnode = makeNode(CreateTransformStmt);

	COPY_SCALAR_FIELD(replace);
	COPY_NODE_FIELD(type_name);
	COPY_STRING_FIELD(lang);
	COPY_NODE_FIELD(fromsql);
	COPY_NODE_FIELD(tosql);

	return fc_newnode;
}

static CreateAmStmt *
fc__copyCreateAmStmt(const CreateAmStmt *fc_from)
{
	CreateAmStmt *fc_newnode = makeNode(CreateAmStmt);

	COPY_STRING_FIELD(amname);
	COPY_NODE_FIELD(handler_name);
	COPY_SCALAR_FIELD(amtype);

	return fc_newnode;
}

static CreateTrigStmt *
fc__copyCreateTrigStmt(const CreateTrigStmt *fc_from)
{
	CreateTrigStmt *fc_newnode = makeNode(CreateTrigStmt);

	COPY_SCALAR_FIELD(replace);
	COPY_SCALAR_FIELD(isconstraint);
	COPY_STRING_FIELD(trigname);
	COPY_NODE_FIELD(relation);
	COPY_NODE_FIELD(funcname);
	COPY_NODE_FIELD(args);
	COPY_SCALAR_FIELD(row);
	COPY_SCALAR_FIELD(timing);
	COPY_SCALAR_FIELD(events);
	COPY_NODE_FIELD(columns);
	COPY_NODE_FIELD(whenClause);
	COPY_NODE_FIELD(transitionRels);
	COPY_SCALAR_FIELD(deferrable);
	COPY_SCALAR_FIELD(initdeferred);
	COPY_NODE_FIELD(constrrel);

	return fc_newnode;
}

static CreateEventTrigStmt *
fc__copyCreateEventTrigStmt(const CreateEventTrigStmt *fc_from)
{
	CreateEventTrigStmt *fc_newnode = makeNode(CreateEventTrigStmt);

	COPY_STRING_FIELD(trigname);
	COPY_STRING_FIELD(eventname);
	COPY_NODE_FIELD(whenclause);
	COPY_NODE_FIELD(funcname);

	return fc_newnode;
}

static AlterEventTrigStmt *
fc__copyAlterEventTrigStmt(const AlterEventTrigStmt *fc_from)
{
	AlterEventTrigStmt *fc_newnode = makeNode(AlterEventTrigStmt);

	COPY_STRING_FIELD(trigname);
	COPY_SCALAR_FIELD(tgenabled);

	return fc_newnode;
}

static CreatePLangStmt *
fc__copyCreatePLangStmt(const CreatePLangStmt *fc_from)
{
	CreatePLangStmt *fc_newnode = makeNode(CreatePLangStmt);

	COPY_SCALAR_FIELD(replace);
	COPY_STRING_FIELD(plname);
	COPY_NODE_FIELD(plhandler);
	COPY_NODE_FIELD(plinline);
	COPY_NODE_FIELD(plvalidator);
	COPY_SCALAR_FIELD(pltrusted);

	return fc_newnode;
}

static CreateRoleStmt *
fc__copyCreateRoleStmt(const CreateRoleStmt *fc_from)
{
	CreateRoleStmt *fc_newnode = makeNode(CreateRoleStmt);

	COPY_SCALAR_FIELD(stmt_type);
	COPY_STRING_FIELD(role);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static AlterRoleStmt *
fc__copyAlterRoleStmt(const AlterRoleStmt *fc_from)
{
	AlterRoleStmt *fc_newnode = makeNode(AlterRoleStmt);

	COPY_NODE_FIELD(role);
	COPY_NODE_FIELD(options);
	COPY_SCALAR_FIELD(action);

	return fc_newnode;
}

static AlterRoleSetStmt *
fc__copyAlterRoleSetStmt(const AlterRoleSetStmt *fc_from)
{
	AlterRoleSetStmt *fc_newnode = makeNode(AlterRoleSetStmt);

	COPY_NODE_FIELD(role);
	COPY_STRING_FIELD(database);
	COPY_NODE_FIELD(setstmt);

	return fc_newnode;
}

static DropRoleStmt *
fc__copyDropRoleStmt(const DropRoleStmt *fc_from)
{
	DropRoleStmt *fc_newnode = makeNode(DropRoleStmt);

	COPY_NODE_FIELD(roles);
	COPY_SCALAR_FIELD(missing_ok);

	return fc_newnode;
}

static LockStmt *
fc__copyLockStmt(const LockStmt *fc_from)
{
	LockStmt   *fc_newnode = makeNode(LockStmt);

	COPY_NODE_FIELD(relations);
	COPY_SCALAR_FIELD(mode);
	COPY_SCALAR_FIELD(nowait);

	return fc_newnode;
}

static ConstraintsSetStmt *
fc__copyConstraintsSetStmt(const ConstraintsSetStmt *fc_from)
{
	ConstraintsSetStmt *fc_newnode = makeNode(ConstraintsSetStmt);

	COPY_NODE_FIELD(constraints);
	COPY_SCALAR_FIELD(deferred);

	return fc_newnode;
}

static ReindexStmt *
fc__copyReindexStmt(const ReindexStmt *fc_from)
{
	ReindexStmt *fc_newnode = makeNode(ReindexStmt);

	COPY_SCALAR_FIELD(kind);
	COPY_NODE_FIELD(relation);
	COPY_STRING_FIELD(name);
	COPY_NODE_FIELD(params);

	return fc_newnode;
}

static CreateSchemaStmt *
fc__copyCreateSchemaStmt(const CreateSchemaStmt *fc_from)
{
	CreateSchemaStmt *fc_newnode = makeNode(CreateSchemaStmt);

	COPY_STRING_FIELD(schemaname);
	COPY_NODE_FIELD(authrole);
	COPY_NODE_FIELD(schemaElts);
	COPY_SCALAR_FIELD(if_not_exists);

	return fc_newnode;
}

static CreateConversionStmt *
fc__copyCreateConversionStmt(const CreateConversionStmt *fc_from)
{
	CreateConversionStmt *fc_newnode = makeNode(CreateConversionStmt);

	COPY_NODE_FIELD(conversion_name);
	COPY_STRING_FIELD(for_encoding_name);
	COPY_STRING_FIELD(to_encoding_name);
	COPY_NODE_FIELD(func_name);
	COPY_SCALAR_FIELD(def);

	return fc_newnode;
}

static CreateCastStmt *
fc__copyCreateCastStmt(const CreateCastStmt *fc_from)
{
	CreateCastStmt *fc_newnode = makeNode(CreateCastStmt);

	COPY_NODE_FIELD(sourcetype);
	COPY_NODE_FIELD(targettype);
	COPY_NODE_FIELD(func);
	COPY_SCALAR_FIELD(context);
	COPY_SCALAR_FIELD(inout);

	return fc_newnode;
}

static PrepareStmt *
fc__copyPrepareStmt(const PrepareStmt *fc_from)
{
	PrepareStmt *fc_newnode = makeNode(PrepareStmt);

	COPY_STRING_FIELD(name);
	COPY_NODE_FIELD(argtypes);
	COPY_NODE_FIELD(query);

	return fc_newnode;
}

static ExecuteStmt *
fc__copyExecuteStmt(const ExecuteStmt *fc_from)
{
	ExecuteStmt *fc_newnode = makeNode(ExecuteStmt);

	COPY_STRING_FIELD(name);
	COPY_NODE_FIELD(params);

	return fc_newnode;
}

static DeallocateStmt *
fc__copyDeallocateStmt(const DeallocateStmt *fc_from)
{
	DeallocateStmt *fc_newnode = makeNode(DeallocateStmt);

	COPY_STRING_FIELD(name);

	return fc_newnode;
}

static DropOwnedStmt *
fc__copyDropOwnedStmt(const DropOwnedStmt *fc_from)
{
	DropOwnedStmt *fc_newnode = makeNode(DropOwnedStmt);

	COPY_NODE_FIELD(roles);
	COPY_SCALAR_FIELD(behavior);

	return fc_newnode;
}

static ReassignOwnedStmt *
fc__copyReassignOwnedStmt(const ReassignOwnedStmt *fc_from)
{
	ReassignOwnedStmt *fc_newnode = makeNode(ReassignOwnedStmt);

	COPY_NODE_FIELD(roles);
	COPY_NODE_FIELD(newrole);

	return fc_newnode;
}

static AlterTSDictionaryStmt *
fc__copyAlterTSDictionaryStmt(const AlterTSDictionaryStmt *fc_from)
{
	AlterTSDictionaryStmt *fc_newnode = makeNode(AlterTSDictionaryStmt);

	COPY_NODE_FIELD(dictname);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static AlterTSConfigurationStmt *
fc__copyAlterTSConfigurationStmt(const AlterTSConfigurationStmt *fc_from)
{
	AlterTSConfigurationStmt *fc_newnode = makeNode(AlterTSConfigurationStmt);

	COPY_SCALAR_FIELD(kind);
	COPY_NODE_FIELD(cfgname);
	COPY_NODE_FIELD(tokentype);
	COPY_NODE_FIELD(dicts);
	COPY_SCALAR_FIELD(override);
	COPY_SCALAR_FIELD(replace);
	COPY_SCALAR_FIELD(missing_ok);

	return fc_newnode;
}

static CreatePolicyStmt *
fc__copyCreatePolicyStmt(const CreatePolicyStmt *fc_from)
{
	CreatePolicyStmt *fc_newnode = makeNode(CreatePolicyStmt);

	COPY_STRING_FIELD(policy_name);
	COPY_NODE_FIELD(table);
	COPY_STRING_FIELD(cmd_name);
	COPY_SCALAR_FIELD(permissive);
	COPY_NODE_FIELD(roles);
	COPY_NODE_FIELD(qual);
	COPY_NODE_FIELD(with_check);

	return fc_newnode;
}

static AlterPolicyStmt *
fc__copyAlterPolicyStmt(const AlterPolicyStmt *fc_from)
{
	AlterPolicyStmt *fc_newnode = makeNode(AlterPolicyStmt);

	COPY_STRING_FIELD(policy_name);
	COPY_NODE_FIELD(table);
	COPY_NODE_FIELD(roles);
	COPY_NODE_FIELD(qual);
	COPY_NODE_FIELD(with_check);

	return fc_newnode;
}

static PartitionElem *
fc__copyPartitionElem(const PartitionElem *fc_from)
{
	PartitionElem *fc_newnode = makeNode(PartitionElem);

	COPY_STRING_FIELD(name);
	COPY_NODE_FIELD(expr);
	COPY_NODE_FIELD(collation);
	COPY_NODE_FIELD(opclass);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static PartitionSpec *
fc__copyPartitionSpec(const PartitionSpec *fc_from)
{
	PartitionSpec *fc_newnode = makeNode(PartitionSpec);

	COPY_STRING_FIELD(strategy);
	COPY_NODE_FIELD(partParams);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static PartitionBoundSpec *
fc__copyPartitionBoundSpec(const PartitionBoundSpec *fc_from)
{
	PartitionBoundSpec *fc_newnode = makeNode(PartitionBoundSpec);

	COPY_SCALAR_FIELD(strategy);
	COPY_SCALAR_FIELD(is_default);
	COPY_SCALAR_FIELD(modulus);
	COPY_SCALAR_FIELD(remainder);
	COPY_NODE_FIELD(listdatums);
	COPY_NODE_FIELD(lowerdatums);
	COPY_NODE_FIELD(upperdatums);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static PartitionRangeDatum *
fc__copyPartitionRangeDatum(const PartitionRangeDatum *fc_from)
{
	PartitionRangeDatum *fc_newnode = makeNode(PartitionRangeDatum);

	COPY_SCALAR_FIELD(kind);
	COPY_NODE_FIELD(value);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static PartitionCmd *
fc__copyPartitionCmd(const PartitionCmd *fc_from)
{
	PartitionCmd *fc_newnode = makeNode(PartitionCmd);

	COPY_NODE_FIELD(name);
	COPY_NODE_FIELD(bound);
	COPY_SCALAR_FIELD(concurrent);

	return fc_newnode;
}

static PublicationObjSpec *
fc__copyPublicationObject(const PublicationObjSpec *fc_from)
{
	PublicationObjSpec *fc_newnode = makeNode(PublicationObjSpec);

	COPY_SCALAR_FIELD(pubobjtype);
	COPY_STRING_FIELD(name);
	COPY_NODE_FIELD(pubtable);
	COPY_LOCATION_FIELD(location);

	return fc_newnode;
}

static PublicationTable *
fc__copyPublicationTable(const PublicationTable *fc_from)
{
	PublicationTable *fc_newnode = makeNode(PublicationTable);

	COPY_NODE_FIELD(relation);
	COPY_NODE_FIELD(whereClause);
	COPY_NODE_FIELD(columns);

	return fc_newnode;
}

static CreatePublicationStmt *
fc__copyCreatePublicationStmt(const CreatePublicationStmt *fc_from)
{
	CreatePublicationStmt *fc_newnode = makeNode(CreatePublicationStmt);

	COPY_STRING_FIELD(pubname);
	COPY_NODE_FIELD(options);
	COPY_NODE_FIELD(pubobjects);
	COPY_SCALAR_FIELD(for_all_tables);

	return fc_newnode;
}

static AlterPublicationStmt *
fc__copyAlterPublicationStmt(const AlterPublicationStmt *fc_from)
{
	AlterPublicationStmt *fc_newnode = makeNode(AlterPublicationStmt);

	COPY_STRING_FIELD(pubname);
	COPY_NODE_FIELD(options);
	COPY_NODE_FIELD(pubobjects);
	COPY_SCALAR_FIELD(for_all_tables);
	COPY_SCALAR_FIELD(action);

	return fc_newnode;
}

static CreateSubscriptionStmt *
fc__copyCreateSubscriptionStmt(const CreateSubscriptionStmt *fc_from)
{
	CreateSubscriptionStmt *fc_newnode = makeNode(CreateSubscriptionStmt);

	COPY_STRING_FIELD(subname);
	COPY_STRING_FIELD(conninfo);
	COPY_NODE_FIELD(publication);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static AlterSubscriptionStmt *
fc__copyAlterSubscriptionStmt(const AlterSubscriptionStmt *fc_from)
{
	AlterSubscriptionStmt *fc_newnode = makeNode(AlterSubscriptionStmt);

	COPY_SCALAR_FIELD(kind);
	COPY_STRING_FIELD(subname);
	COPY_STRING_FIELD(conninfo);
	COPY_NODE_FIELD(publication);
	COPY_NODE_FIELD(options);

	return fc_newnode;
}

static DropSubscriptionStmt *
fc__copyDropSubscriptionStmt(const DropSubscriptionStmt *fc_from)
{
	DropSubscriptionStmt *fc_newnode = makeNode(DropSubscriptionStmt);

	COPY_STRING_FIELD(subname);
	COPY_SCALAR_FIELD(missing_ok);
	COPY_SCALAR_FIELD(behavior);

	return fc_newnode;
}

/* ****************************************************************
 *					extensible.h 复制函数
 * ****************************************************************
 */
static ExtensibleNode *
fc__copyExtensibleNode(const ExtensibleNode *fc_from)
{
	ExtensibleNode *fc_newnode;
	const ExtensibleNodeMethods *fc_methods;

	fc_methods = GetExtensibleNodeMethods(fc_from->extnodename, false);
	fc_newnode = (ExtensibleNode *) newNode(fc_methods->node_size,
										 T_ExtensibleNode);
	COPY_STRING_FIELD(extnodename);

	/* 复制私有字段 */
	fc_methods->nodeCopy(fc_newnode, fc_from);

	return fc_newnode;
}

/* ****************************************************************
 *					value.h 复制函数
 * ****************************************************************
 */
static Integer *
fc__copyInteger(const Integer *fc_from)
{
	Integer    *fc_newnode = makeNode(Integer);

	COPY_SCALAR_FIELD(ival);

	return fc_newnode;
}

static Float *
fc__copyFloat(const Float *fc_from)
{
	Float	   *fc_newnode = makeNode(Float);

	COPY_STRING_FIELD(fval);

	return fc_newnode;
}

static Boolean *
fc__copyBoolean(const Boolean *fc_from)
{
	Boolean    *fc_newnode = makeNode(Boolean);

	COPY_SCALAR_FIELD(boolval);

	return fc_newnode;
}

static String *
fc__copyString(const String *fc_from)
{
	String	   *fc_newnode = makeNode(String);

	COPY_STRING_FIELD(sval);

	return fc_newnode;
}

static BitString *
fc__copyBitString(const BitString *fc_from)
{
	BitString  *fc_newnode = makeNode(BitString);

	COPY_STRING_FIELD(bsval);

	return fc_newnode;
}


static ForeignKeyCacheInfo *
fc__copyForeignKeyCacheInfo(const ForeignKeyCacheInfo *fc_from)
{
	ForeignKeyCacheInfo *fc_newnode = makeNode(ForeignKeyCacheInfo);

	COPY_SCALAR_FIELD(conoid);
	COPY_SCALAR_FIELD(conrelid);
	COPY_SCALAR_FIELD(confrelid);
	COPY_SCALAR_FIELD(nkeys);
	COPY_ARRAY_FIELD(conkey);
	COPY_ARRAY_FIELD(confkey);
	COPY_ARRAY_FIELD(conpfeqop);

	return fc_newnode;
}

/*
 * copyObjectImpl -- copyObject() 的实现；见 nodes/nodes.h
 *
 * 创建一个节点树或列表的副本。这是一个 "深度" 复制：所有
 * 子结构也会递归复制。
 */
void * copyObjectImpl(const void *fc_from)
{
	void	   *fc_retval;

	if (fc_from == NULL)
		return NULL;

	/* 防止因过于复杂的表达式导致栈溢出 */
	check_stack_depth();

	switch (nodeTag(fc_from))
	{
			/*
			 * 计划节点
			 */
		case T_PlannedStmt:
			fc_retval = fc__copyPlannedStmt(fc_from);
			break;
		case T_Plan:
			fc_retval = fc__copyPlan(fc_from);
			break;
		case T_Result:
			fc_retval = fc__copyResult(fc_from);
			break;
		case T_ProjectSet:
			fc_retval = fc__copyProjectSet(fc_from);
			break;
		case T_ModifyTable:
			fc_retval = fc__copyModifyTable(fc_from);
			break;
		case T_Append:
			fc_retval = fc__copyAppend(fc_from);
			break;
		case T_MergeAppend:
			fc_retval = fc__copyMergeAppend(fc_from);
			break;
		case T_RecursiveUnion:
			fc_retval = fc__copyRecursiveUnion(fc_from);
			break;
		case T_BitmapAnd:
			fc_retval = fc__copyBitmapAnd(fc_from);
			break;
		case T_BitmapOr:
			fc_retval = fc__copyBitmapOr(fc_from);
			break;
		case T_Scan:
			fc_retval = fc__copyScan(fc_from);
			break;
		case T_Gather:
			fc_retval = fc__copyGather(fc_from);
			break;
		case T_GatherMerge:
			fc_retval = fc__copyGatherMerge(fc_from);
			break;
		case T_SeqScan:
			fc_retval = fc__copySeqScan(fc_from);
			break;
		case T_SampleScan:
			fc_retval = fc__copySampleScan(fc_from);
			break;
		case T_IndexScan:
			fc_retval = fc__copyIndexScan(fc_from);
			break;
		case T_IndexOnlyScan:
			fc_retval = fc__copyIndexOnlyScan(fc_from);
			break;
		case T_BitmapIndexScan:
			fc_retval = fc__copyBitmapIndexScan(fc_from);
			break;
		case T_BitmapHeapScan:
			fc_retval = fc__copyBitmapHeapScan(fc_from);
			break;
		case T_TidScan:
			fc_retval = fc__copyTidScan(fc_from);
			break;
		case T_TidRangeScan:
			fc_retval = fc__copyTidRangeScan(fc_from);
			break;
		case T_SubqueryScan:
			fc_retval = fc__copySubqueryScan(fc_from);
			break;
		case T_FunctionScan:
			fc_retval = fc__copyFunctionScan(fc_from);
			break;
		case T_TableFuncScan:
			fc_retval = fc__copyTableFuncScan(fc_from);
			break;
		case T_ValuesScan:
			fc_retval = fc__copyValuesScan(fc_from);
			break;
		case T_CteScan:
			fc_retval = fc__copyCteScan(fc_from);
			break;
		case T_NamedTuplestoreScan:
			fc_retval = fc__copyNamedTuplestoreScan(fc_from);
			break;
		case T_WorkTableScan:
			fc_retval = fc__copyWorkTableScan(fc_from);
			break;
		case T_ForeignScan:
			fc_retval = fc__copyForeignScan(fc_from);
			break;
		case T_CustomScan:
			fc_retval = fc__copyCustomScan(fc_from);
			break;
		case T_Join:
			fc_retval = fc__copyJoin(fc_from);
			break;
		case T_NestLoop:
			fc_retval = fc__copyNestLoop(fc_from);
			break;
		case T_MergeJoin:
			fc_retval = fc__copyMergeJoin(fc_from);
			break;
		case T_HashJoin:
			fc_retval = fc__copyHashJoin(fc_from);
			break;
		case T_Material:
			fc_retval = fc__copyMaterial(fc_from);
			break;
		case T_Memoize:
			fc_retval = fc__copyMemoize(fc_from);
			break;
		case T_Sort:
			fc_retval = fc__copySort(fc_from);
			break;
		case T_IncrementalSort:
			fc_retval = fc__copyIncrementalSort(fc_from);
			break;
		case T_Group:
			fc_retval = fc__copyGroup(fc_from);
			break;
		case T_Agg:
			fc_retval = fc__copyAgg(fc_from);
			break;
		case T_WindowAgg:
			fc_retval = fc__copyWindowAgg(fc_from);
			break;
		case T_Unique:
			fc_retval = fc__copyUnique(fc_from);
			break;
		case T_Hash:
			fc_retval = fc__copyHash(fc_from);
			break;
		case T_SetOp:
			fc_retval = fc__copySetOp(fc_from);
			break;
		case T_LockRows:
			fc_retval = fc__copyLockRows(fc_from);
			break;
		case T_Limit:
			fc_retval = fc__copyLimit(fc_from);
			break;
		case T_NestLoopParam:
			fc_retval = fc__copyNestLoopParam(fc_from);
			break;
		case T_PlanRowMark:
			fc_retval = fc__copyPlanRowMark(fc_from);
			break;
		case T_PartitionPruneInfo:
			fc_retval = fc__copyPartitionPruneInfo(fc_from);
			break;
		case T_PartitionedRelPruneInfo:
			fc_retval = fc__copyPartitionedRelPruneInfo(fc_from);
			break;
		case T_PartitionPruneStepOp:
			fc_retval = fc__copyPartitionPruneStepOp(fc_from);
			break;
		case T_PartitionPruneStepCombine:
			fc_retval = fc__copyPartitionPruneStepCombine(fc_from);
			break;
		case T_PlanInvalItem:
			fc_retval = fc__copyPlanInvalItem(fc_from);
			break;

			/*
			 * 基本节点
			 */
		case T_Alias:
			fc_retval = fc__copyAlias(fc_from);
			break;
		case T_RangeVar:
			fc_retval = fc__copyRangeVar(fc_from);
			break;
		case T_TableFunc:
			fc_retval = fc__copyTableFunc(fc_from);
			break;
		case T_IntoClause:
			fc_retval = fc__copyIntoClause(fc_from);
			break;
		case T_Var:
			fc_retval = fc__copyVar(fc_from);
			break;
		case T_Const:
			fc_retval = fc__copyConst(fc_from);
			break;
		case T_Param:
			fc_retval = fc__copyParam(fc_from);
			break;
		case T_Aggref:
			fc_retval = fc__copyAggref(fc_from);
			break;
		case T_GroupingFunc:
			fc_retval = fc__copyGroupingFunc(fc_from);
			break;
		case T_WindowFunc:
			fc_retval = fc__copyWindowFunc(fc_from);
			break;
		case T_SubscriptingRef:
			fc_retval = fc__copySubscriptingRef(fc_from);
			break;
		case T_FuncExpr:
			fc_retval = fc__copyFuncExpr(fc_from);
			break;
		case T_NamedArgExpr:
			fc_retval = fc__copyNamedArgExpr(fc_from);
			break;
		case T_OpExpr:
			fc_retval = fc__copyOpExpr(fc_from);
			break;
		case T_DistinctExpr:
			fc_retval = fc__copyDistinctExpr(fc_from);
			break;
		case T_NullIfExpr:
			fc_retval = fc__copyNullIfExpr(fc_from);
			break;
		case T_ScalarArrayOpExpr:
			fc_retval = fc__copyScalarArrayOpExpr(fc_from);
			break;
		case T_BoolExpr:
			fc_retval = fc__copyBoolExpr(fc_from);
			break;
		case T_SubLink:
			fc_retval = fc__copySubLink(fc_from);
			break;
		case T_SubPlan:
			fc_retval = fc__copySubPlan(fc_from);
			break;
		case T_AlternativeSubPlan:
			fc_retval = fc__copyAlternativeSubPlan(fc_from);
			break;
		case T_FieldSelect:
			fc_retval = fc__copyFieldSelect(fc_from);
			break;
		case T_FieldStore:
			fc_retval = fc__copyFieldStore(fc_from);
			break;
		case T_RelabelType:
			fc_retval = fc__copyRelabelType(fc_from);
			break;
		case T_CoerceViaIO:
			fc_retval = fc__copyCoerceViaIO(fc_from);
			break;
		case T_ArrayCoerceExpr:
			fc_retval = fc__copyArrayCoerceExpr(fc_from);
			break;
		case T_ConvertRowtypeExpr:
			fc_retval = fc__copyConvertRowtypeExpr(fc_from);
			break;
		case T_CollateExpr:
			fc_retval = fc__copyCollateExpr(fc_from);
			break;
		case T_CaseExpr:
			fc_retval = fc__copyCaseExpr(fc_from);
			break;
		case T_CaseWhen:
			fc_retval = fc__copyCaseWhen(fc_from);
			break;
		case T_CaseTestExpr:
			fc_retval = fc__copyCaseTestExpr(fc_from);
			break;
		case T_ArrayExpr:
			fc_retval = fc__copyArrayExpr(fc_from);
			break;
		case T_RowExpr:
			fc_retval = fc__copyRowExpr(fc_from);
			break;
		case T_RowCompareExpr:
			fc_retval = fc__copyRowCompareExpr(fc_from);
			break;
		case T_CoalesceExpr:
			fc_retval = fc__copyCoalesceExpr(fc_from);
			break;
		case T_MinMaxExpr:
			fc_retval = fc__copyMinMaxExpr(fc_from);
			break;
		case T_SQLValueFunction:
			fc_retval = fc__copySQLValueFunction(fc_from);
			break;
		case T_XmlExpr:
			fc_retval = fc__copyXmlExpr(fc_from);
			break;
		case T_NullTest:
			fc_retval = fc__copyNullTest(fc_from);
			break;
		case T_BooleanTest:
			fc_retval = fc__copyBooleanTest(fc_from);
			break;
		case T_CoerceToDomain:
			fc_retval = fc__copyCoerceToDomain(fc_from);
			break;
		case T_CoerceToDomainValue:
			fc_retval = fc__copyCoerceToDomainValue(fc_from);
			break;
		case T_SetToDefault:
			fc_retval = fc__copySetToDefault(fc_from);
			break;
		case T_CurrentOfExpr:
			fc_retval = fc__copyCurrentOfExpr(fc_from);
			break;
		case T_NextValueExpr:
			fc_retval = fc__copyNextValueExpr(fc_from);
			break;
		case T_InferenceElem:
			fc_retval = fc__copyInferenceElem(fc_from);
			break;
		case T_TargetEntry:
			fc_retval = fc__copyTargetEntry(fc_from);
			break;
		case T_RangeTblRef:
			fc_retval = fc__copyRangeTblRef(fc_from);
			break;
		case T_JoinExpr:
			fc_retval = fc__copyJoinExpr(fc_from);
			break;
		case T_FromExpr:
			fc_retval = fc__copyFromExpr(fc_from);
			break;
		case T_OnConflictExpr:
			fc_retval = fc__copyOnConflictExpr(fc_from);
			break;

			/*
			 * 关系节点
			 */
		case T_PathKey:
			fc_retval = fc__copyPathKey(fc_from);
			break;
		case T_RestrictInfo:
			fc_retval = fc__copyRestrictInfo(fc_from);
			break;
		case T_PlaceHolderVar:
			fc_retval = fc__copyPlaceHolderVar(fc_from);
			break;
		case T_SpecialJoinInfo:
			fc_retval = fc__copySpecialJoinInfo(fc_from);
			break;
		case T_AppendRelInfo:
			fc_retval = fc__copyAppendRelInfo(fc_from);
			break;
		case T_PlaceHolderInfo:
			fc_retval = fc__copyPlaceHolderInfo(fc_from);
			break;

			/*
			 * 值节点
			 */
		case T_Integer:
			fc_retval = fc__copyInteger(fc_from);
			break;
		case T_Float:
			fc_retval = fc__copyFloat(fc_from);
			break;
		case T_Boolean:
			fc_retval = fc__copyBoolean(fc_from);
			break;
		case T_String:
			fc_retval = fc__copyString(fc_from);
			break;
		case T_BitString:
			fc_retval = fc__copyBitString(fc_from);
			break;

			/*
			 * 列表节点
			 */
		case T_List:
			fc_retval = list_copy_deep(fc_from);
			break;

			/*
			 * 整数和OID的列表不需要深拷贝，因此我们通过list_copy()执行浅拷贝
			 */
		case T_IntList:
		case T_OidList:
			fc_retval = list_copy(fc_from);
			break;

			/*
			 * 可扩展节点
			 */
		case T_ExtensibleNode:
			fc_retval = fc__copyExtensibleNode(fc_from);
			break;

			/*
			 * 解析节点
			 */
		case T_Query:
			fc_retval = fc__copyQuery(fc_from);
			break;
		case T_RawStmt:
			fc_retval = fc__copyRawStmt(fc_from);
			break;
		case T_InsertStmt:
			fc_retval = fc__copyInsertStmt(fc_from);
			break;
		case T_DeleteStmt:
			fc_retval = fc__copyDeleteStmt(fc_from);
			break;
		case T_UpdateStmt:
			fc_retval = fc__copyUpdateStmt(fc_from);
			break;
		case T_MergeStmt:
			fc_retval = fc__copyMergeStmt(fc_from);
			break;
		case T_SelectStmt:
			fc_retval = fc__copySelectStmt(fc_from);
			break;
		case T_SetOperationStmt:
			fc_retval = fc__copySetOperationStmt(fc_from);
			break;
		case T_ReturnStmt:
			fc_retval = fc__copyReturnStmt(fc_from);
			break;
		case T_PLAssignStmt:
			fc_retval = fc__copyPLAssignStmt(fc_from);
			break;
		case T_AlterTableStmt:
			fc_retval = fc__copyAlterTableStmt(fc_from);
			break;
		case T_AlterTableCmd:
			fc_retval = fc__copyAlterTableCmd(fc_from);
			break;
		case T_AlterCollationStmt:
			fc_retval = fc__copyAlterCollationStmt(fc_from);
			break;
		case T_AlterDomainStmt:
			fc_retval = fc__copyAlterDomainStmt(fc_from);
			break;
		case T_GrantStmt:
			fc_retval = fc__copyGrantStmt(fc_from);
			break;
		case T_GrantRoleStmt:
			fc_retval = fc__copyGrantRoleStmt(fc_from);
			break;
		case T_AlterDefaultPrivilegesStmt:
			fc_retval = fc__copyAlterDefaultPrivilegesStmt(fc_from);
			break;
		case T_DeclareCursorStmt:
			fc_retval = fc__copyDeclareCursorStmt(fc_from);
			break;
		case T_ClosePortalStmt:
			fc_retval = fc__copyClosePortalStmt(fc_from);
			break;
		case T_CallStmt:
			fc_retval = fc__copyCallStmt(fc_from);
			break;
		case T_ClusterStmt:
			fc_retval = fc__copyClusterStmt(fc_from);
			break;
		case T_CopyStmt:
			fc_retval = fc__copyCopyStmt(fc_from);
			break;
		case T_CreateStmt:
			fc_retval = fc__copyCreateStmt(fc_from);
			break;
		case T_TableLikeClause:
			fc_retval = fc__copyTableLikeClause(fc_from);
			break;
		case T_DefineStmt:
			fc_retval = fc__copyDefineStmt(fc_from);
			break;
		case T_DropStmt:
			fc_retval = fc__copyDropStmt(fc_from);
			break;
		case T_TruncateStmt:
			fc_retval = fc__copyTruncateStmt(fc_from);
			break;
		case T_CommentStmt:
			fc_retval = fc__copyCommentStmt(fc_from);
			break;
		case T_SecLabelStmt:
			fc_retval = fc__copySecLabelStmt(fc_from);
			break;
		case T_FetchStmt:
			fc_retval = fc__copyFetchStmt(fc_from);
			break;
		case T_IndexStmt:
			fc_retval = fc__copyIndexStmt(fc_from);
			break;
		case T_CreateStatsStmt:
			fc_retval = fc__copyCreateStatsStmt(fc_from);
			break;
		case T_AlterStatsStmt:
			fc_retval = fc__copyAlterStatsStmt(fc_from);
			break;
		case T_CreateFunctionStmt:
			fc_retval = fc__copyCreateFunctionStmt(fc_from);
			break;
		case T_FunctionParameter:
			fc_retval = fc__copyFunctionParameter(fc_from);
			break;
		case T_AlterFunctionStmt:
			fc_retval = fc__copyAlterFunctionStmt(fc_from);
			break;
		case T_DoStmt:
			fc_retval = fc__copyDoStmt(fc_from);
			break;
		case T_RenameStmt:
			fc_retval = fc__copyRenameStmt(fc_from);
			break;
		case T_AlterObjectDependsStmt:
			fc_retval = fc__copyAlterObjectDependsStmt(fc_from);
			break;
		case T_AlterObjectSchemaStmt:
			fc_retval = fc__copyAlterObjectSchemaStmt(fc_from);
			break;
		case T_AlterOwnerStmt:
			fc_retval = fc__copyAlterOwnerStmt(fc_from);
			break;
		case T_AlterOperatorStmt:
			fc_retval = fc__copyAlterOperatorStmt(fc_from);
			break;
		case T_AlterTypeStmt:
			fc_retval = fc__copyAlterTypeStmt(fc_from);
			break;
		case T_RuleStmt:
			fc_retval = fc__copyRuleStmt(fc_from);
			break;
		case T_NotifyStmt:
			fc_retval = fc__copyNotifyStmt(fc_from);
			break;
		case T_ListenStmt:
			fc_retval = fc__copyListenStmt(fc_from);
			break;
		case T_UnlistenStmt:
			fc_retval = fc__copyUnlistenStmt(fc_from);
			break;
		case T_TransactionStmt:
			fc_retval = fc__copyTransactionStmt(fc_from);
			break;
		case T_CompositeTypeStmt:
			fc_retval = fc__copyCompositeTypeStmt(fc_from);
			break;
		case T_CreateEnumStmt:
			fc_retval = fc__copyCreateEnumStmt(fc_from);
			break;
		case T_CreateRangeStmt:
			fc_retval = fc__copyCreateRangeStmt(fc_from);
			break;
		case T_AlterEnumStmt:
			fc_retval = fc__copyAlterEnumStmt(fc_from);
			break;
		case T_ViewStmt:
			fc_retval = fc__copyViewStmt(fc_from);
			break;
		case T_LoadStmt:
			fc_retval = fc__copyLoadStmt(fc_from);
			break;
		case T_CreateDomainStmt:
			fc_retval = fc__copyCreateDomainStmt(fc_from);
			break;
		case T_CreateOpClassStmt:
			fc_retval = fc__copyCreateOpClassStmt(fc_from);
			break;
		case T_CreateOpClassItem:
			fc_retval = fc__copyCreateOpClassItem(fc_from);
			break;
		case T_CreateOpFamilyStmt:
			fc_retval = fc__copyCreateOpFamilyStmt(fc_from);
			break;
		case T_AlterOpFamilyStmt:
			fc_retval = fc__copyAlterOpFamilyStmt(fc_from);
			break;
		case T_CreatedbStmt:
			fc_retval = fc__copyCreatedbStmt(fc_from);
			break;
		case T_AlterDatabaseStmt:
			fc_retval = fc__copyAlterDatabaseStmt(fc_from);
			break;
		case T_AlterDatabaseRefreshCollStmt:
			fc_retval = fc__copyAlterDatabaseRefreshCollStmt(fc_from);
			break;
		case T_AlterDatabaseSetStmt:
			fc_retval = fc__copyAlterDatabaseSetStmt(fc_from);
			break;
		case T_DropdbStmt:
			fc_retval = fc__copyDropdbStmt(fc_from);
			break;
		case T_VacuumStmt:
			fc_retval = fc__copyVacuumStmt(fc_from);
			break;
		case T_VacuumRelation:
			fc_retval = fc__copyVacuumRelation(fc_from);
			break;
		case T_ExplainStmt:
			fc_retval = fc__copyExplainStmt(fc_from);
			break;
		case T_CreateTableAsStmt:
			fc_retval = fc__copyCreateTableAsStmt(fc_from);
			break;
		case T_RefreshMatViewStmt:
			fc_retval = fc__copyRefreshMatViewStmt(fc_from);
			break;
		case T_ReplicaIdentityStmt:
			fc_retval = fc__copyReplicaIdentityStmt(fc_from);
			break;
		case T_AlterSystemStmt:
			fc_retval = fc__copyAlterSystemStmt(fc_from);
			break;
		case T_CreateSeqStmt:
			fc_retval = fc__copyCreateSeqStmt(fc_from);
			break;
		case T_AlterSeqStmt:
			fc_retval = fc__copyAlterSeqStmt(fc_from);
			break;
		case T_VariableSetStmt:
			fc_retval = fc__copyVariableSetStmt(fc_from);
			break;
		case T_VariableShowStmt:
			fc_retval = fc__copyVariableShowStmt(fc_from);
			break;
		case T_DiscardStmt:
			fc_retval = fc__copyDiscardStmt(fc_from);
			break;
		case T_CreateTableSpaceStmt:
			fc_retval = fc__copyCreateTableSpaceStmt(fc_from);
			break;
		case T_DropTableSpaceStmt:
			fc_retval = fc__copyDropTableSpaceStmt(fc_from);
			break;
		case T_AlterTableSpaceOptionsStmt:
			fc_retval = fc__copyAlterTableSpaceOptionsStmt(fc_from);
			break;
		case T_AlterTableMoveAllStmt:
			fc_retval = fc__copyAlterTableMoveAllStmt(fc_from);
			break;
		case T_CreateExtensionStmt:
			fc_retval = fc__copyCreateExtensionStmt(fc_from);
			break;
		case T_AlterExtensionStmt:
			fc_retval = fc__copyAlterExtensionStmt(fc_from);
			break;
		case T_AlterExtensionContentsStmt:
			fc_retval = fc__copyAlterExtensionContentsStmt(fc_from);
			break;
		case T_CreateFdwStmt:
			fc_retval = fc__copyCreateFdwStmt(fc_from);
			break;
		case T_AlterFdwStmt:
			fc_retval = fc__copyAlterFdwStmt(fc_from);
			break;
		case T_CreateForeignServerStmt:
			fc_retval = fc__copyCreateForeignServerStmt(fc_from);
			break;
		case T_AlterForeignServerStmt:
			fc_retval = fc__copyAlterForeignServerStmt(fc_from);
			break;
		case T_CreateUserMappingStmt:
			fc_retval = fc__copyCreateUserMappingStmt(fc_from);
			break;
		case T_AlterUserMappingStmt:
			fc_retval = fc__copyAlterUserMappingStmt(fc_from);
			break;
		case T_DropUserMappingStmt:
			fc_retval = fc__copyDropUserMappingStmt(fc_from);
			break;
		case T_CreateForeignTableStmt:
			fc_retval = fc__copyCreateForeignTableStmt(fc_from);
			break;
		case T_ImportForeignSchemaStmt:
			fc_retval = fc__copyImportForeignSchemaStmt(fc_from);
			break;
		case T_CreateTransformStmt:
			fc_retval = fc__copyCreateTransformStmt(fc_from);
			break;
		case T_CreateAmStmt:
			fc_retval = fc__copyCreateAmStmt(fc_from);
			break;
		case T_CreateTrigStmt:
			fc_retval = fc__copyCreateTrigStmt(fc_from);
			break;
		case T_CreateEventTrigStmt:
			fc_retval = fc__copyCreateEventTrigStmt(fc_from);
			break;
		case T_AlterEventTrigStmt:
			fc_retval = fc__copyAlterEventTrigStmt(fc_from);
			break;
		case T_CreatePLangStmt:
			fc_retval = fc__copyCreatePLangStmt(fc_from);
			break;
		case T_CreateRoleStmt:
			fc_retval = fc__copyCreateRoleStmt(fc_from);
			break;
		case T_AlterRoleStmt:
			fc_retval = fc__copyAlterRoleStmt(fc_from);
			break;
		case T_AlterRoleSetStmt:
			fc_retval = fc__copyAlterRoleSetStmt(fc_from);
			break;
		case T_DropRoleStmt:
			fc_retval = fc__copyDropRoleStmt(fc_from);
			break;
		case T_LockStmt:
			fc_retval = fc__copyLockStmt(fc_from);
			break;
		case T_ConstraintsSetStmt:
			fc_retval = fc__copyConstraintsSetStmt(fc_from);
			break;
		case T_ReindexStmt:
			fc_retval = fc__copyReindexStmt(fc_from);
			break;
		case T_CheckPointStmt:
			fc_retval = (void *) makeNode(CheckPointStmt);
			break;
		case T_CreateSchemaStmt:
			fc_retval = fc__copyCreateSchemaStmt(fc_from);
			break;
		case T_CreateConversionStmt:
			fc_retval = fc__copyCreateConversionStmt(fc_from);
			break;
		case T_CreateCastStmt:
			fc_retval = fc__copyCreateCastStmt(fc_from);
			break;
		case T_PrepareStmt:
			fc_retval = fc__copyPrepareStmt(fc_from);
			break;
		case T_ExecuteStmt:
			fc_retval = fc__copyExecuteStmt(fc_from);
			break;
		case T_DeallocateStmt:
			fc_retval = fc__copyDeallocateStmt(fc_from);
			break;
		case T_DropOwnedStmt:
			fc_retval = fc__copyDropOwnedStmt(fc_from);
			break;
		case T_ReassignOwnedStmt:
			fc_retval = fc__copyReassignOwnedStmt(fc_from);
			break;
		case T_AlterTSDictionaryStmt:
			fc_retval = fc__copyAlterTSDictionaryStmt(fc_from);
			break;
		case T_AlterTSConfigurationStmt:
			fc_retval = fc__copyAlterTSConfigurationStmt(fc_from);
			break;
		case T_CreatePolicyStmt:
			fc_retval = fc__copyCreatePolicyStmt(fc_from);
			break;
		case T_AlterPolicyStmt:
			fc_retval = fc__copyAlterPolicyStmt(fc_from);
			break;
		case T_CreatePublicationStmt:
			fc_retval = fc__copyCreatePublicationStmt(fc_from);
			break;
		case T_AlterPublicationStmt:
			fc_retval = fc__copyAlterPublicationStmt(fc_from);
			break;
		case T_CreateSubscriptionStmt:
			fc_retval = fc__copyCreateSubscriptionStmt(fc_from);
			break;
		case T_AlterSubscriptionStmt:
			fc_retval = fc__copyAlterSubscriptionStmt(fc_from);
			break;
		case T_DropSubscriptionStmt:
			fc_retval = fc__copyDropSubscriptionStmt(fc_from);
			break;
		case T_A_Expr:
			fc_retval = fc__copyA_Expr(fc_from);
			break;
		case T_ColumnRef:
			fc_retval = fc__copyColumnRef(fc_from);
			break;
		case T_ParamRef:
			fc_retval = fc__copyParamRef(fc_from);
			break;
		case T_A_Const:
			fc_retval = fc__copyA_Const(fc_from);
			break;
		case T_FuncCall:
			fc_retval = fc__copyFuncCall(fc_from);
			break;
		case T_A_Star:
			fc_retval = fc__copyA_Star(fc_from);
			break;
		case T_A_Indices:
			fc_retval = fc__copyA_Indices(fc_from);
			break;
		case T_A_Indirection:
			fc_retval = fc__copyA_Indirection(fc_from);
			break;
		case T_A_ArrayExpr:
			fc_retval = fc__copyA_ArrayExpr(fc_from);
			break;
		case T_ResTarget:
			fc_retval = fc__copyResTarget(fc_from);
			break;
		case T_MultiAssignRef:
			fc_retval = fc__copyMultiAssignRef(fc_from);
			break;
		case T_TypeCast:
			fc_retval = fc__copyTypeCast(fc_from);
			break;
		case T_CollateClause:
			fc_retval = fc__copyCollateClause(fc_from);
			break;
		case T_SortBy:
			fc_retval = fc__copySortBy(fc_from);
			break;
		case T_WindowDef:
			fc_retval = fc__copyWindowDef(fc_from);
			break;
		case T_RangeSubselect:
			fc_retval = fc__copyRangeSubselect(fc_from);
			break;
		case T_RangeFunction:
			fc_retval = fc__copyRangeFunction(fc_from);
			break;
		case T_RangeTableSample:
			fc_retval = fc__copyRangeTableSample(fc_from);
			break;
		case T_RangeTableFunc:
			fc_retval = fc__copyRangeTableFunc(fc_from);
			break;
		case T_RangeTableFuncCol:
			fc_retval = fc__copyRangeTableFuncCol(fc_from);
			break;
		case T_TypeName:
			fc_retval = fc__copyTypeName(fc_from);
			break;
		case T_IndexElem:
			fc_retval = fc__copyIndexElem(fc_from);
			break;
		case T_StatsElem:
			fc_retval = fc__copyStatsElem(fc_from);
			break;
		case T_ColumnDef:
			fc_retval = fc__copyColumnDef(fc_from);
			break;
		case T_Constraint:
			fc_retval = fc__copyConstraint(fc_from);
			break;
		case T_DefElem:
			fc_retval = fc__copyDefElem(fc_from);
			break;
		case T_LockingClause:
			fc_retval = fc__copyLockingClause(fc_from);
			break;
		case T_RangeTblEntry:
			fc_retval = fc__copyRangeTblEntry(fc_from);
			break;
		case T_RangeTblFunction:
			fc_retval = fc__copyRangeTblFunction(fc_from);
			break;
		case T_TableSampleClause:
			fc_retval = fc__copyTableSampleClause(fc_from);
			break;
		case T_WithCheckOption:
			fc_retval = fc__copyWithCheckOption(fc_from);
			break;
		case T_SortGroupClause:
			fc_retval = fc__copySortGroupClause(fc_from);
			break;
		case T_GroupingSet:
			fc_retval = fc__copyGroupingSet(fc_from);
			break;
		case T_WindowClause:
			fc_retval = fc__copyWindowClause(fc_from);
			break;
		case T_RowMarkClause:
			fc_retval = fc__copyRowMarkClause(fc_from);
			break;
		case T_WithClause:
			fc_retval = fc__copyWithClause(fc_from);
			break;
		case T_InferClause:
			fc_retval = fc__copyInferClause(fc_from);
			break;
		case T_OnConflictClause:
			fc_retval = fc__copyOnConflictClause(fc_from);
			break;
		case T_CTESearchClause:
			fc_retval = fc__copyCTESearchClause(fc_from);
			break;
		case T_CTECycleClause:
			fc_retval = fc__copyCTECycleClause(fc_from);
			break;
		case T_CommonTableExpr:
			fc_retval = fc__copyCommonTableExpr(fc_from);
			break;
		case T_MergeWhenClause:
			fc_retval = fc__copyMergeWhenClause(fc_from);
			break;
		case T_MergeAction:
			fc_retval = fc__copyMergeAction(fc_from);
			break;
		case T_ObjectWithArgs:
			fc_retval = fc__copyObjectWithArgs(fc_from);
			break;
		case T_AccessPriv:
			fc_retval = fc__copyAccessPriv(fc_from);
			break;
		case T_XmlSerialize:
			fc_retval = fc__copyXmlSerialize(fc_from);
			break;
		case T_RoleSpec:
			fc_retval = fc__copyRoleSpec(fc_from);
			break;
		case T_TriggerTransition:
			fc_retval = fc__copyTriggerTransition(fc_from);
			break;
		case T_PartitionElem:
			fc_retval = fc__copyPartitionElem(fc_from);
			break;
		case T_PartitionSpec:
			fc_retval = fc__copyPartitionSpec(fc_from);
			break;
		case T_PartitionBoundSpec:
			fc_retval = fc__copyPartitionBoundSpec(fc_from);
			break;
		case T_PartitionRangeDatum:
			fc_retval = fc__copyPartitionRangeDatum(fc_from);
			break;
		case T_PartitionCmd:
			fc_retval = fc__copyPartitionCmd(fc_from);
			break;
		case T_PublicationObjSpec:
			fc_retval = fc__copyPublicationObject(fc_from);
			break;
		case T_PublicationTable:
			fc_retval = fc__copyPublicationTable(fc_from);
			break;

			/*
			 * 杂项节点
			 */
		case T_ForeignKeyCacheInfo:
			fc_retval = fc__copyForeignKeyCacheInfo(fc_from);
			break;

		default:
			elog(ERROR, "unrecognized node type: %d", (int) nodeTag(fc_from));
			fc_retval = 0;			/* 保持编译器安静 */
			break;
	}

	return fc_retval;
}
